Some postings ago I reported about how to use modified RSA_numbers_factored.py in MicroPython on micro controller (just for fun).
Today during long hike with dog in forest I wanted to compute some RSA number related formula.
I used small values of primes p and q and the unique sum of squares for them.
In the end I had to use normal smartphone calculator to compute remainders of division.
So I asked myself whether I can run Python on Android.
Simple answer is yes, and there are alternatives.
I decided to go with non-free Pydroid3 (3 days free test, then 2$/month or 16$/lifetime).
After installing I was able to compute "2**65537 % 65537" in the forest thanks to Python.
At home I told my older son, and he did not search in playstore but in search engine.
He came up with open source QPython, but that asked to install from playstore, and playstore said that it cannot install on my Android 11.
So I will go with Pydroid3. Initially I selected weekly charge for 3 days free testing.
It turned out not to be possible to change that to lifetime during free 3-day trial.
I canceled subscription and will buy lifetime after free trial ends on Monday.
The first small scripts were easy to type in and run.
Installation of sympy was easy as well with builtin Pip (see left below).
Running mathplotlib example automatically installed mathplotlib and produced nice 3D function on display.
So I wanted to copy RSA_numbers_factored.py onto smartphone, but did not find the right directory.
This posting revealed the lib directory:
https://stackoverflow.com/a/70714408/5674289
On my Android it was Python 3.9:
Code: Select all
/data/user/0/ru.iiec.pydroid3/files/aarch64-linux-android/lib/python3.9
So I uploaded RSA_numbers_factored.py with AndFTP onto smartphone Download directory.
Then opened with Pydroid3, and stored with "save as" in Pydroid3 internal filesystem under above directory.
Next I created small Pydroid3_demo.py:
https://github.com/Hermann-SW/RSA_numbe ... d3_demo.py
That was necessary since test __name__ == "__main__" does not work in Pydroid3.
And uploaded it into Internal storage/Documents/Pydroid3 directory.
Finally I opened in Pydroid3 (see middle) and clicked run button at bottom.
The output of demo can be seen right:

- Pydroid3_demo.jpg
- Pydroid3_demo.jpg (101.49 KiB) Viewed 4645 times
So cool to be able to run Python, with sympy, mathplotlib, arbitrary precision arithmetic, ... anywhere even offline without connectivity.
I added new section "Non-standard Python environments" to github repo (with MicroPython and Android subsections):
https://github.com/Hermann-SW/RSA_numbe ... vironments