Use only "gaussian" tool, under symbolic link "square_sum_prod".
Assert on even or "≡3 (mod 4)" factors.
Instead of "a + b*i" output "(a**2 + b**2)".
Output " * " between factors, and final " == " followed by input.
Because of Fermat's theorem on sums of two squares each factor "≡1 (mod 4)" has unique representation as sum of two squares.
@alpertron's cool gaussian calculator allows to process 120-digit number in less than a second !
Just "make" shows demo after build:
pi@pi400-64:~/square_sum_prod $ make
./square_sum_prod 97
(9**2 + 4**2) == 97
./square_sum_prod 169 py
3,2,3,2
./square_sum_prod 693342667110830181197325401899700641361965863127336680673013|\
python -c 'import sys;l=sys.stdin.read().rstrip();print(l,"\n"+str(eval(l)))'
(832050675380196295918334279642**2 + 32161167736719180733109944457**2) == 693342667110830181197325401899700641361965863127336680673013
True
./square_sum_prod 1105|\
python -c 'import sys;l=sys.stdin.read().rstrip();print(l,"\n"+str(eval(l)))'
(2**2 + 1**2) * (3**2 + 2**2) * (4**2 + 1**2) == 1105
True
pi@pi400-64:~/square_sum_prod $
Second example demonstrates quick and dirty Python support, see comments in Popen.py for details (I know that dirty remains long after quick is gone).
Computing unique sum of squares for primes ≡1 (mod 4) took:
- 0.1s for 198-digit prime on Raspberry Pi400 with A72 CPU
- 3s for 2082-digit prime on Intel i7-1165G7 CPU
- 2:32min (only) for 10001-digit prime on i7-1165G7
Computation as well as Python verification for 10001-digit prime is here, better for browser view here.
Results of static analysis and code coverage of this software using Codacy.
Badges from SonarCloud:
If you like these calculators and you want to support free software, you can donate by clicking in one of the buttons below:
