fork(5) download
  1. __help__ = """In the forloop I'm setting the values i to n.
  2. To be a "notPrimes", it's n % i == 0 if: 1 < i, i < n. (We
  3. do tests i<1/2 i==1, too). Then, prints resulting, prime text.
  4. In case i==n: quit. Just if it aborts: try."""
  5.  
  6. # read integer from command line
  7. n=int(input())
  8.  
  9. try:
  10.  
  11. # primes = True
  12. notPrimes = False
  13.  
  14. # try each i to n
  15. for i in range(n):
  16.  
  17. # ignore 0 or 1
  18. if i < 1 / 2 or i == 1:
  19. continue
  20.  
  21. # test divisibility
  22. if n % i == 0:
  23. notPrimes = True
  24.  
  25. # print result
  26. if notPrimes:
  27. print("not prime")
  28. else:
  29. print("prime")
  30.  
  31. except:
  32.  
  33. # if program aborts: print help and error code
  34. print(__help__ [::7])
  35.  
Success #stdin #stdout 0.04s 9488KB
stdin
7
stdout
prime