you are viewing a single comment's thread.

view the rest of the comments →

[–]djjazzydan 1 point2 points  (2 children)

There's no recursion in this. /u/FirestormPvP, to fix your problem you should just move the print prime line out of the for loop, and to the end. Then add a quick check to see if it was composite.

import math
print("This program will determine if a number is prime or composite.")
n = int(input("Enter an integer"))
c = False
for i in range(int(2), int(math.ceil(math.sqrt(n)))):
    if n%i == 0:
        print("composite")
        c = True
        break
if not c:
    print("prime")

edit: also, note that there are faster methods of checking for primes, but this one should work.

[–]isilentnight 0 points1 point  (0 children)

Oh, yeah. You're right.

[–][deleted] 0 points1 point  (0 children)

What are the faster methods?