Skip to content

Commit

Permalink
Merge pull request #341 from shushantkumar/master
Browse files Browse the repository at this point in the history
  • Loading branch information
sbshah97 authored Oct 10, 2017
2 parents ea8200c + 99ae9d4 commit 02864c9
Showing 1 changed file with 23 additions and 0 deletions.
23 changes: 23 additions & 0 deletions shushantkumar/sieve_of_erastothenes.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
//shushantkumar
#include <stdio.h>
#include <stdlib.h>

int main(){
int *prime;
prime = malloc(sizeof(int) * 1000);
long int i,j;
for (i = 2;i < 1000; i++)
prime[i] = 1;

for (i = 2;i < 1000; i++)
if (prime[i])
for (j = i;i * j < 1000; j++)
prime[i * j] = 0;

printf("Prime numbers in range 1 to 1000 are: \n");
for (j = 2;j < 1000; j++)
if (prime[j])
printf("%d\n", j);

return 0;
}

0 comments on commit 02864c9

Please sign in to comment.