#include<stdio.h>

int main(int argc,char *argv[])

{

int N,i,j,sum=0,count;

if(argc!=2)

exit(1);

N=atoi(argv[1]);

for(i=2;i<=N;i++)

{

count=1;

for(j=2;j<=i/2;j++)

{

if(i%j==0)

{

count=0;

break;

}

}

if(count==1)

{

sum=sum+i;

}

}

printf("Sum of all prime numbers between 1 to %d=%d",N,sum);

return 0;

}

Contributed by

int main(int argc,char *argv[])

{

int N,i,j,sum=0,count;

if(argc!=2)

exit(1);

N=atoi(argv[1]);

for(i=2;i<=N;i++)

{

count=1;

for(j=2;j<=i/2;j++)

{

if(i%j==0)

{

count=0;

break;

}

}

if(count==1)

{

sum=sum+i;

}

}

printf("Sum of all prime numbers between 1 to %d=%d",N,sum);

return 0;

}

Contributed by

**Priti Lohia**
## No comments:

## Post a Comment