[ create a new paste ] login | about

Link: http://codepad.org/MhHw8qAg    [ raw code | output | fork ]

C, pasted on Sep 25:
#include <stdlib.h>
#include <stdio.h>

rnd5(){
return (rand()%5) + 1;
}

rnd7(){
int a = rnd5() + rnd5() + rnd5() + rnd5() + rnd5() + rnd5() + rnd5();
int b = (a % 7) + 1;
return b;
} 

void main()
{
int l[]={0,0,0,0,0,0,0,0,0,0,};
int i;
for(i=0;i<1000000;i++){
l[rnd7()]++;
}

for(i=1;i<=7;i++) {
printf("%d\n", l[i]);
}
}


Output:
1
2
3
4
5
6
7
143066
142794
143041
142941
142313
142553
143292


Create a new paste based on this one


Comments: