CloDz

Prime Numbers Finder Minimal

Sep 21st, 2020
860
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. def number_range_function():
  2.     num_range = []
  3.     print("Input lower limit:")
  4.     lower = int(input())
  5.     print("Input upper limit:")
  6.     upper = int(input())
  7.     while upper > lower:
  8.         num_range.append(lower)
  9.         lower += 1
  10.     num_range.append(lower)
  11.     return num_range
  12. def prime_finder(num_range):
  13.     num_check = 2
  14.     prime = []
  15.     for i in num_range:
  16.         while num_check <= i:
  17.             if i % num_check != 0:
  18.                 num_check += 1
  19.             elif num_check == i:
  20.                 prime.append(i)
  21.                 num_check = 2
  22.                 break
  23.             else:
  24.                 break
  25.     print("Prime Numbers Are (Total of {} out of {} numbers.):".format(len(prime),len(num_range)))
  26.     print("{}".format(prime))
  27. number_range = number_range_function()
  28. prime_finder(number_range)
  29. exit()
RAW Paste Data