dividing two array elements
Posted
by
pradeep
on Stack Overflow
See other posts from Stack Overflow
or by pradeep
Published on 2010-12-24T10:37:30Z
Indexed on
2010/12/24
12:54 UTC
Read the original article
Hit count: 155
c
main()
{
int prime_array[2339],prime1_count=0,mul1_count=0;
int i, prime, lim_up, lim_low, n,j=0;
int mul,count=0;
int mul_count[65026]={0},number[7096];
printf("\n ENTER THE LOWER LIMIT…: ");
scanf("%d", &lim_low);
printf("\n ENTER THE UPPER LIMIT…: ");
scanf("%d", &lim_up);
for(n=lim_low+1; n<lim_up; n++)
{
prime = 1;
for(i=2; i<n; i++)
if(n%i == 0)
{
prime = 0;
break;
}
if(prime)
{
prime_array[j]=n;
j++;
}
}
for(i=1;i<=255;i++)
{
for(j=1;j<=255;j++)
{
mul = j*i;
mul_count[mul]++;
}
}
for(i=1;i<=65025;i++)
if( mul_count[i]!=2 && mul_count[i]!=0 )
{
number[count]=i;
count++;
}
for(prime1_count=0;prime1_count<2339;prime1_count++)
{
printf("\nprime number used is:%d",prime_array[prime1_count]);
for(mul1_count=0;mul1_count<7096;mul1_count++)
{
printf("\n%d\t",number[mul1_count] % prime_array[prime1_count]);
}
}
}
I want to find the modulus of (number[mul1_count] % prime_array[prime1_count] )
, but the output which I get is wrong. What is the mistake here. The prime number should be in the range 40000 to 65025. What changes should i make here?
© Stack Overflow or respective owner