+ 1

# Primes Calc

How can i find the all primes less than number 'n'? https://code.sololearn.com/cs16oBO8dMVg/?ref=app

2 Answers

+ 2

you save every prime you find and a prime is a number which is not divideable by any prime number before
so if n is bigger then 2 you add 2 to your primearray. now for every number till n you iterate over your primearray and check if the current number modulo every number in the array is >0 if this is true you add the number to your prime array if not you take the next number and do the same...
! do not add 1 to the prime array but dont forget to print it for completion

+ 2

I have solved the problem in my code. Thank you for your attention.