Welcome
Python 3.14 in the page: exact big integers, fractions, a prime sieve and Markdown cells.
basicsprogrammingDownload (ZIP)Source on GitHub
Preview
Welcome to Sagebrush
Python 3.14, compiled to JavaScript, runs in this page: nothing is sent anywhere. Press Shift+Enter to run a cell (or Run all above). This is a Markdown cell: double-click it to edit. It can have lists, tables, code, links and math:
How it is built: articles on the open-source (MIT/Apache) engines behind this page, from Gröbner bases and FGLM to modular symbols, Galois groups and class groups: how each algorithm works, what worked, what did not.
# Big integers are exact
2**2001606938044258990275541962092341162602522202993782792835301376
from fractions import Fraction
H = sum(Fraction(1, n) for n in range(1, 31))
H, float(H)(Fraction(9304682830147, 2329089562800), 3.994987130920391)
def primes(n):
sieve = bytearray([1]) * (n + 1)
sieve[:2] = b'\x00\x00'
for p in range(2, int(n**0.5) + 1):
if sieve[p]:
sieve[p*p::p] = bytes(len(range(p*p, n + 1, p)))
return [i for i, ok in enumerate(sieve) if ok]
ps = primes(10**5)
print(len(ps), ps[-5:])9592 [99929, 99961, 99971, 99989, 99991]
import cmath
[cmath.exp(2j * cmath.pi * k / 6) for k in range(3)][(1+0j), (0.5000000000000001+0.8660254037844386j), (-0.4999999999999998+0.8660254037844387j)]
Files
main.ipynb(2491 bytes)