Advertisement
jukaukor

Factoring_int.py

Aug 8th, 2019
158
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.51 KB | None | 0 0
  1. # Factors of Integer is product of two primes
  2. # Juhani Kaukoranta 8.8.2019
  3. import math
  4. import time
  5. from numba import njit
  6. @njit
  7. def factor(n):
  8. for x in range(3, int(math.sqrt(n)) + 1,2):
  9. if n % x == 0:
  10. p = x
  11. q = n // x
  12. return [p,q]
  13. n = int(input("Anna kokonaisluku, jonka tulontekijät lasketaan: "))
  14. time0 = time.perf_counter() # timer begin
  15. print("tekijät = ",factor(n))
  16. time1 = time.perf_counter() # timer stop
  17. print("Aikaa kului ",time1 - time0," sekuntia")
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement