`Member 13095321`

,There is a mistake in this line:

Copy Code

for(i=2; i<=n; ++i)It should be,

Copy Code

for(i=2; i<n; ++i)Also there is no need to run up to n for checking divisibility. Half of that number is fine. Say n=37, then there is no need to loop up to 36 to check the divisibility; looping up to n/2 = 18 would be fine as later numbers (19, 20,....) are not factors of 36.

There are other efficient approaches for finding primes. You can try them as well.

If I run your code and pass in '0' and '10' to the program the output I get is:

1100000000

You need to test more before submitting.

Also, your teacher is unlikely to be impressed by your implementation.

Seek thee the Sieve of Eratosthenes.

Make a Sieve from 2 to e (pre-fill 0 and 1), then index into it to get the values for s through e.