Answers for "how to make prime and composite numbers on python"

0

python program to find n prime numbers

num = 10
for i in range(2,num+1):
    for j in range(2,i):
        if(i%j == 0):
            break
    else:
        print(i)
Posted by: Guest on March-10-2021
1

prime number in python

a=int(input('number:'))
if a % 2 ==0 and a / 2 <= 2:
    print('composite')
elif a % 3 == 0 and a/3 <= 2:
    print('composit')
elif a % 5 == 0 and a/5 <= 2 :
    print('composit')
elif a % 7 == 0 and a/7 <= 2:
    print('composit')
else:
    print('prime')
________________________________________________________________________________
Posted by: Guest on December-13-2021

Code answers related to "how to make prime and composite numbers on python"

Python Answers by Framework

Browse Popular Code Answers by Language