Skip to content

Instantly share code, notes, and snippets.

@tpott
Created August 8, 2019 04:40
Show Gist options
  • Save tpott/f150f63bcbafbc05d269a99dc325771e to your computer and use it in GitHub Desktop.
Save tpott/f150f63bcbafbc05d269a99dc325771e to your computer and use it in GitHub Desktop.
$ python rosetta.py 5000000 | shuf -n2
1099489
4113097
$ calc '1099489*4113097'
4522304907433
$ pypy easy_primes.py -f 4522304907433 -t 1100000 -v
Largest prime 1100009
Searching for factors of 4522304907433 up to 2126572 (except not really)
Previously unfound/unknown prime: 4113097
Successfully found factors: 1099489 * 4113097
$ python3
>>> base64.b16encode(int.to_bytes(4522304907433, length=8, byteorder='big', signed=True))
b'0000041CEE60A8A9'
>>> list(map(int, int.to_bytes(4522304907433, length=8, byteorder='big', signed=True)))
[0, 0, 4, 28, 238, 96, 168, 169]
>>> list(map(int, int.to_bytes(1099489, length=8, byteorder='big', signed=True)))
[0, 0, 0, 0, 0, 16, 198, 225]
>>> list(map(int, int.to_bytes(4113097, length=8, byteorder='big', signed=True)))
[0, 0, 0, 0, 0, 62, 194, 201]
$ python2
>>> from scipy.fftpack import (fft, ifft)
>>> import numpy as np
>>> ifft(np.multiply(fft([0, 0, 0, 0, 0, 16, 198, 225]), fft([0, 0, 0, 0, 0, 62, 194, 201]))).real
array([-7.27595761e-12, 0.00000000e+00, 9.92000000e+02, 1.53800000e+04,
5.55780000e+04, 8.34480000e+04, 4.52250000e+04, -7.27595761e-12])
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment