Data update

This commit is contained in:
Ingy döt Net 2026-04-30 12:34:36 -04:00
parent 4bb20c9b71
commit cbaf4c4b64
12390 changed files with 318560 additions and 27248 deletions

View file

@ -1,6 +1,6 @@
arr[] = [ 2 ]
fastproc .
for i = 2 to 9
for i = 2 to 8
k = 3
repeat
em = 1

View file

@ -0,0 +1,18 @@
(do ;;; find elements of the Euclid-Mullin sequence: starting from 2,
;;; the next element is the smallest prime factor of 1 + the product
;;; of the previous elements
(io.write "2")
(var product 2)
(for [i 2 9]
(var (nextV p found) (values (+ product 1) 3 false))
; find the first prime factor of nextV
(while (and (<= (* p p) nextV) (not found))
(set found (= 0 (% nextV p)))
(when (not found) (set p (+ p 2)))
)
(when found (set nextV p))
(io.write (.. " " nextV))
(set product (* product nextV))
)
)

View file

@ -0,0 +1,57 @@
//
// Euclid-Mullin Sequence
// Using FutureBasic 7.0.35
//
// September 2025, R.W.
//
include "gmp.incl"
_TERMS = 16 // first 16 EuclidMullin Sequence
// Return a non-trivial factor of n using Pollard-Rho
void local fn PollardRho( n as mpz_t, out as mpz_t )
mpz_t x,y,c,d,absDiff
mpz_inits( x, y, c, d, absDiff, 0 )
mpz_set_ui( x, 2 ) : mpz_set_ui( y, 2 ) : mpz_set_ui( c, 1 )
mpz_set_ui( d, 1 )
while fn mpz_cmp_ui( d, 1 ) == 0
// x = (x*x + c) mod n
mpz_mul( x, x, x ) : mpz_add( x, x, c ) : mpz_mod( x, x, n )
// y = f(f(y))
mpz_mul( y, y, y ) : mpz_add( y, y, c ) : mpz_mod( y, y, n )
mpz_mul( y, y, y ) : mpz_add( y, y, c ) : mpz_mod( y, y, n )
// d = gcd(|x-y|, n)
mpz_sub( absDiff, x, y ) : mpz_abs( absDiff, absDiff )
fn mpz_gcd( d, absDiff, n )
wend
mpz_set( out, d )
mpz_clears( x,y,c,d,absDiff,0 )
end fn
void local fn EuclidMullin( terms as long )
CFStringRef result
mpz_t total, tmp, factor
mpz_inits( total, tmp, factor, 0 )
mpz_set_ui( total, 1 )
print @
print @"First ";terms;" numbers of Euclid-Mullin sequence"
print @
long k
for k = 1 to _TERMS
mpz_add_ui( tmp, total, 1 ) // tmp = total + 1
fn PollardRho( tmp, factor ) // factor = some factor of tmp
result = fn mpz_cf2( factor )
print result
mpz_mul( total, total, factor ) // total *= factor
next
mpz_clears( total, tmp, factor, 0 )
end fn
window 1, @"Euclid-Mullin Sequence"
fn EuclidMullin(_TERMS )
handleEvents

View file

@ -0,0 +1,20 @@
let product = 2n;
function smallestPrimeFactor(number) {
if (number % 3n === 0n) { return 3n; }
if (number % 5n === 0n) { return 5n; }
for (let divisor = 7n; divisor * divisor <= number; divisor += 2n) {
if (number % divisor === 0n) { return divisor; }
}
return number;
}
function nextEuclidMullin() {
const smallestPrime = smallestPrimeFactor(product + 1n);
product *= smallestPrime;
return smallestPrime;
}
console.log("The first 9 terms of the Euclid-Mullin sequence:");
process.stdout.write(2 + " ");
for (let i = 1; i < 9; ++i) {
process.stdout.write(nextEuclidMullin() + " ");
}
console.log("\n");

View file

@ -4,7 +4,7 @@
do
io.write( "2" )
local product = 2
for i = 2, 8 do
for i = 2, 9 do
local nextV, p, found = product + 1, 3, false
-- find the first prime factor of nextV
while p * p <= nextV and not found do

View file

@ -0,0 +1,29 @@
MODULE EuclidMullinSequence; (* find elements of the Euclid-Mullin sequence: *)
IMPORT Out; (* starting from 2, the next element is the smallest *)
(* prime factor of 1 + the product of the previous *)
(* elements *)
(* assuming INTEGER is 32-bit, we should be able to *)
(* find 8 elements, before the product overflows *)
VAR product, i, nextV, p : INTEGER;
found : BOOLEAN;
BEGIN
Out.String( "2" );
product := 2;
FOR i := 2 TO 8 DO
nextV := product + 1;
(* find the first prime factor of nextV *)
p := 3;
found := FALSE;
WHILE ~ found & ( p * p <= nextV ) DO
found := nextV MOD p = 0;
IF ~ found THEN INC( p, 2 ) END
END;
IF found THEN nextV := p END;
Out.String( " " );Out.Int( nextV, 0 );
product := product * nextV
END
END EuclidMullinSequence.

View file

@ -0,0 +1,29 @@
MODULE EuclidMullinSequence; (* find elements of the Euclid-Mullin sequence: *)
IMPORT Out; (* starting from 2, the next element is the smallest *)
(* prime factor of 1 + the product of the previous *)
(* elements *)
(* assuming LONGINT is 64-bit, we should be able to *)
(* find 9 elements, before the product overflows *)
VAR product, i, nextV, p : LONGINT;
found : BOOLEAN;
BEGIN
Out.String( "2" );
product := 2;
FOR i := 2 TO 9 DO
nextV := product + 1;
(* find the first prime factor of nextV *)
p := 3;
found := FALSE;
WHILE ~ found & ( p * p <= nextV ) DO
found := nextV MOD p = 0;
IF ~ found THEN INC( p, 2 ) END
END;
IF found THEN nextV := p END;
Out.String( " " );Out.Int( nextV, 0 );
product := product * nextV
END
END EuclidMullinSequence.

View file

@ -0,0 +1,22 @@
-- find elements of the Euclid-Mullin sequence: starting from 2,
-- the next element is the smallest prime factor of 1 + the product
-- of the previous elements
do
local bigint = require( "pluto:bigint" ) -- use the standard bigint library
io.write( "2" )
local b0 <const>, b1 <const>, b2 <const>, b3 <const>
= new bigint( 0 ), new bigint( 1 ), new bigint( 2 ), new bigint( 3 )
local product = new bigint( 2 )
for _ = 2, 16 do
local nextV, p, found = product + b1, b3, false
-- find the first prime factor of nextV
while p * p <= nextV and not found do
found = nextV % p == b0
if not found then p += b2 end
end
if found then nextV = p end
io.write( $" { nextV:tostring() }" )
product *= nextV
end
end

View file

@ -0,0 +1,10 @@
library(gmp)
next_term <- function(v) min(factorize(prod(v)+1))
euclid_mullin <- function(n){
v <- as.bigz(2)
replicate(n-1, v <<- c(v, next_term(v)))
print(v, initLine=FALSE)
}
euclid_mullin(16)