Write an algorithm to find prime numbers between 1 to 10. | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
0

Write an algorithm to find prime numbers between 1 to 10.

only algorithim

25th Aug 2020, 2:11 AM
SOM SATWIK DEO
SOM SATWIK DEO - avatar
2 Answers
+ 2
This trick also works for fetching prime numbers from 1 to 100 🔴Get numbers from 1 to 100 🔴 Remove 1 because it is neither prime nor composite. 🔴 If a number except 2 is divisible by 2, remove them from list. eg: remove:4,6,8,10,... 🔴 remove all the numbers that are divisible by 3 except 3 itself. eg: remove 9, 15, 21,... 🔴 Similarly remove all the numbers divisible by 5 except 5. Now the numbers left are prime
25th Aug 2020, 3:06 AM
Satyam Mishra
Satyam Mishra - avatar
0
This is very useful for me thanks
7th Feb 2023, 6:45 PM
Subash Bhai
Subash Bhai - avatar