B03D-2015D – Computer Sir Ki Class

Login


Lost your password?

Don't have an account ?
Register (It's FREE) ×
  

Login
[lwa]



Exam Questions-CBSE12D-2015-B03D #PYTHON#6542    siteicon   siteicon  

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

TC++ #6542

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)


Share

CSKC| Created: 14-Jan-2019 | Updated: 14-Jan-2019|CBSE12D-2015









Back