B03D-2016D – Computer Sir Ki Class

Login


Lost your password?

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

Login
[lwa]



Exam Questions-CBSE12D-2016-B03D #PYTHON#6486    siteicon   siteicon  

Problem Statement - B03D-2016D

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++ #6486

def prime(N):
    for a in range(2,N):
        for I in range(2,a):
            if N%i ==0:
        break
        print a
OR
def prime(N):
    for a in range(2,N):
        for I in range(2,a):
            if a%i ==0:
        break
            else:
            print a


Share

CSKC| Created: 12-Jan-2019 | Updated: 12-Jan-2019|CBSE12D-2016









Back