Problem Statement - B03D-2015D
Write a method in python to find and display the prime numbers between 2 to N. Pass N as argument to the method.
Solution
CSKC| Created: 14-Jan-2019 | Updated: 14-Jan-2019|CBSE12D-2015
Write a method in python to find and display the prime numbers between 2 to N. Pass N as argument to the method.
|
def prime_numbers(N): for I in range(2, N+1): M = I // 2 IsPrime=1 for J in range(2, M+1): if I % J == 0: IsPrime=0 break if IsPrime==1: print(I)
CSKC| Created: 14-Jan-2019 | Updated: 14-Jan-2019|CBSE12D-2015