Answer to Question #322621 in Python for lokesh

Question #322621

First Prime Number:


(1) Input: 5 Output: 3

1

10

4

3

2


(2) Input: 4 Output: 2

2

3

5

7


1
Expert's answer
2022-04-03T08:00:03-0400
i = 1
x = int(input("Enter the number:"))
for k in range(1, x+1):
    c = 0
    for j in range(1, i+1):
        a = i % j
        if a == 0:
            c = c + 1

    if c == 2:
        print(i)
    else:
        k = k - 1

    i = i + 1

Need a fast expert's response?

Submit order

and get a quick answer at the best price

for any assignment or question with DETAILED EXPLANATIONS!

Comments

No comments. Be the first!

Leave a comment

LATEST TUTORIALS
New on Blog
APPROVED BY CLIENTS