Print prime numbers from 1 to n

i made a pseudocode for print the prime numbers from one to n i have two doubts 1) is my code complete 2) is second loop starts from 2 i guess ryt pls correct me where i wrong and suggest the code

hello @dipeshgupta197

start j from 1 and run till j <=i .

other than that its ok

yes…

why we take j=1 as i is always divisible by 1

for primes total two divisors are there 1 and the numer itself .

thats why iterating from 1 to n and counting divisors

I hope I’ve cleared your doubt. I ask you to please rate your experience here
Your feedback is very important. It helps us improve our platform and hence provide you
the learning experience you deserve.

On the off chance, you still have some questions or not find the answers satisfactory, you may reopen
the doubt.