# Product of modulo valuesby Quezif

Time for something a little nerdier:

I stumbled across this last semester when I wrote a program to spit out times tables under different modulo values ([link]). I noticed a pattern, so I decided to get it to spit out an image instead of a table.

This image is essentially a times table. Each pixel starting from the top left hand corner is one multiplication. Any pixel i,j holds a value of i*j (mod 1009), where black is zero, and pure white is a value of 1008

Without ranting too much, my jaw dropped when I saw this. If you follow all the details in it, there's so many overlapping patterns nested in it. And it's just multiplication. That something so simple could produce something so intricate and brain-breakish speaks volumes about how cool math actually is

If you want to play with this, here's the C code for it (it saves using netbpm because I'm lazy and didn't want to screw around with external packages, just use Google if you need to find a converter and don't want to modify the code). It'll ask you for a modulo value, so you can produce whatever size image you want

I'm planning on generalising this to real numbers rather than integers at some stage, and also making it produce a colour image. If someone plays with this, please let me know and I'll put your code up here with proper attribution.

---------------------------------------------

#include <stdio.h>
#include <stdlib.h>

int main()
{
int j,k, value, MODULO;

FILE *file;

printf("Enter a modulo value:");
fscanf(stdin,"%d",&MODULO);

printf("Started...\n");
file=fopen("modulo.pgm","w");

fprintf(file,"%s\n","P2");
fprintf(file,"%5d %5d\n", MODULO, MODULO);
fprintf(file,"%d",(MODULO-1));

for (j=0;j<MODULO;j++)
{
fprintf(file,"\n");
for (k=0;k<MODULO;k++)
{
value= j*k%MODULO;
fprintf(file," %5d ", value);

}
printf("%d\n",j);
}
fclose(file);
printf("Finished\n");
return EXIT_SUCCESS;
}
Featured By Owner Nov 16, 2012
I made some matlab code in imitation of this. Here's a gif of what happens when you vary the modulus from 1 to 1000, linearly.

Featured By Owner Nov 16, 2012
Oh that link doesn't work, but I can't figure out how to remove it. My bad
Featured By Owner Nov 16, 2012
Can you post your code in a comment, assuming it's small?

Submitted on
November 7, 2012
Image Size
470 KB
Resolution
1009×1009
Thumb
Embed

Views
571
Favourites
1 (who?)