ecm

Elliptic Curve factorization - code and slides
git clone https://git.tronto.net/ecm
Download | Log | Files | Refs | README

naive.py (294B)


      1 #!/bin/env python
      2 
      3 from sys import argv
      4 from math import floor, sqrt
      5 
      6 def naive_factor(n: int) -> int:
      7 	for i in range(2,floor(sqrt(n))+1):
      8 		if n%i == 0:
      9 			return i
     10 	else:
     11 		return -1
     12 
     13 N = int(argv[-1])
     14 f = naive_factor(N)
     15 if f == -1:
     16 	print(N, "is prime")
     17 else:
     18 	print(N, "=", f, "*", N//f)