Create a function that takes in a positive integer and return a list of prime numbers. A prime number is only divisible by 1 and itself.
Answers
Answered by
2
Function that takes in a positive integer and return a list of prime numbers
Answer:
CODE:
def prime(n):
start = 1
for val in range(start,n+1):
if val > 1:
for j in range(2, val):
if (val % j) == 0:
break
else:
print(val)
a=int(input("Enter an integer:"))
prime(a)
OUTPUT:
Enter an integer:20
2
3
5
7
11
13
17
19
TO KNOW MORE:
1.Write a python program to create a tuple storing prime numbers in given range.
https://brainly.in/question/14217352
2.Program for whether the no.is prime or not.In Python
https://brainly.in/question/14176156
Similar questions
Hindi,
5 months ago
Computer Science,
9 months ago
Computer Science,
9 months ago
Physics,
1 year ago