- 3
Write a program to show the prime numbers from 1 to 100
5 Respostas
+ 12
Give input as 100 to this code.
https://code.sololearn.com/cx1fwlL103Es/?ref=app
+ 11
https://code.sololearn.com/cMIpx9pnzVcn/?ref=app
+ 1
Show me yours and I'll show you mine ;-)
Here's what I used in my Python routine (I'll add the link later):
- 2 is the only even prime. For the rest, you only need to check the odd numbers.
- If a number is a square number like 3*3, 5*5, it is not prime
- The highest divisor that you need to check cannot be higher than the square root of each number.
There you go: https://code.sololearn.com/cQ03qEe16RQw
+ 1
https://code.sololearn.com/cMC3JLRv0T04/?ref=app
input: begin end
example: for input string "4 120" program prints a prime numbers in range from 4 to 120.