https://en.wikipedia.org/wiki/PARI/GP

https://pari.math.u-bordeaux.fr/

Developed since the early eighties in the University of Bordeaux, PARI is free software, available under the GPL.

Pari is a C library, gp its command line interface.

I found this nice (4 pages) reference card:

https://math.mit.edu/~brubaker/PARI/PARIrefcard.pdf

You can play with Pari/GP without installation in your browser:

https://pari.math.u-bordeaux.fr/gp.html

I am interested in fast multiple precision integer arithmetic and integer factorization with my RSA_numbers_factored project in Python+gmpy2+sympy sofar.

Pari comes with all that, and while it has weaknesses (string handling, no memoization), this statement is killer argument for Pari/GP for me:

https://oeis.org/wiki/PARI/GP#Comparison_to_other_CAS

In the domain of number theory, PARI/GP is a strong rival to well established all-purpose CAS as Maple and Mathematica,mainly due to its computational speed, where it typically outperforms both of these well known commercial CAS, and its free availability.

After

Code: Select all

`sudo apt install pari-gp`

Simple factorization example in command line interpreter:

Code: Select all

```
pi@pi400-64:~/Documents $ gp -q
? print(factorint(2^ 256-1))
[3, 1; 5, 1; 17, 1; 257, 1; 641, 1; 65537, 1; 274177, 1; 6700417, 1; 67280421310721, 1; 59649589127497217, 1; 5704689200685129054721, 1]
?
```

gp can execute scripts as well, or like this:

Code: Select all

```
pi@pi400-64:~ $ gp -q <(echo "print(factorint(2^256-1));quit")
[3, 1; 5, 1; 17, 1; 257, 1; 641, 1; 65537, 1; 274177, 1; 6700417, 1; 67280421310721, 1; 59649589127497217, 1; 5704689200685129054721, 1]
pi@pi400-64:~ $
```

This is "factorint()" doc from page 193 of 675 pages manual:

https://pari.math.u-bordeaux.fr/pub/par ... f#page=193

Smallest RSA number from RSA_numbers_factored repo is 59 decimal digits number RSA-59 (biggest numbers are RSA-617 and RSA-2048):

Code: Select all

```
pi@pi400-64:~/RSA_numbers_factored/python $ python -q
>>> from RSA_numbers_factored import RSA, digits
>>> R = RSA()
>>> l,n,p,q = R.get(59)[0:4]
>>> print(l,n,p,q)
59 71641520761751435455133616475667090434063332228247871795429 200429218120815554269743635437 357440504101388365610785389017
>>> l == digits(n) and n == p * q
True
>>>
```

I started Python sympy factorint 65 minutes ago on Pi400, and it has not completed yet:

Code: Select all

`pi@pi400-64:~/RSA_numbers_factored/python $ python <(echo "from sympy import factorint; print(factorint(71641520761751435455133616475667090434063332228247871795429))")`

This is a wow for Pari/GP for me — only 12 seconds for factoring RSA-59 with Pari/GP on my (1.8GHz default) Raspberry Pi400:

Code: Select all

```
pi@pi400-64:~ $ time gp -q <(echo "print(factorint(71641520761751435455133616475667090434063332228247871795429));quit")
[200429218120815554269743635437, 1; 357440504101388365610785389017, 1]
real 0m12.048s
user 0m11.971s
sys 0m0.030s
pi@pi400-64:~ $
```

Just to be clear, Pari/GP factorint is nice, but surely is no help to factor any RSA number above biggest factored sofar RSA number RSA-250. But it will surely be a cool addition to Python+gmpy2+sympy in my tool chest!