Hi to the forum;
A simple question:
I want to make a prime number checker:
So if I want to test if 25 is a prime number.
i should to verify if 2 is a factor.
if it is not, i verify with 3 and 4 (not my subject if not 4 id included in not 2), and finally 5.

with a for loop,

for i in range (2, 25):
    if 25 % i == 0:
        break
    else:
        print (25, " is a prime number.")

is a wrong code because after testing 25 % 2, the conclusion where that 25 is a prime number.
So it is imperative that the condition controlled loop run's from 2 to 24(I know the exageration but It's not my subject).

What is the right procedure?

Recommended Answers

All 3 Replies

Thank so much!
It is precisely the response!
It is a simple trivial question but i don't regret. It's ggod to read a good answer!

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.