Data update

This commit is contained in:
Ingy döt Net 2024-10-16 18:07:41 -07:00
parent 81fd053722
commit 52a6ef48dd
10248 changed files with 63654 additions and 6775 deletions

View file

@ -0,0 +1,30 @@
#include <cstdint>
#include <iostream>
uint64_t product = 2;
uint64_t smallest_prime_factor(const uint64_t& number) {
if ( number % 3 == 0 ) { return 3; }
if ( number % 5 == 0 ) { return 5; }
for ( uint64_t divisor = 7; divisor * divisor <= number; divisor += 2 ) {
if ( number % divisor == 0 ) { return divisor; }
}
return number;
}
uint64_t next_euclid_mullin() {
const uint64_t smallest_prime = smallest_prime_factor(product + 1);
product *= smallest_prime;
return smallest_prime;
}
int main() {
std::cout << "The first 9 terms of the Euclid-Mullin sequence:" << "\n";
std::cout << 2 << " ";
for ( uint32_t i = 1; i < 9; ++i ) {
std::cout << next_euclid_mullin() << " ";
}
std::cout << "\n";
}

View file

@ -12,7 +12,8 @@ public final class EuclidMullinSequence {
System.out.println("The first 27 terms of the Euclid-Mullin sequence:");
System.out.print(2 + " ");
for ( int i = 1; i < 27; i++ ) {
System.out.print(String.format("%s%s", nextEuclidMullin(), ( i == 14 || i == 27 ) ? "\n" : " "));
System.out.print(
String.format("%s%s", nextEuclidMullin(), ( i == 14 || i == 27 ) ? "\n" : " "));
}
}
@ -67,7 +68,7 @@ public final class EuclidMullinSequence {
sieve.set(2, aLimit + 1);
for ( int i = 2; i * i <= aLimit; i = sieve.nextSetBit(i + 1) ) {
for ( int j = i * i; j <= aLimit; j = j + i ) {
for ( int j = i * i; j <= aLimit; j += i ) {
sieve.clear(j);
}
}

View file

@ -0,0 +1,29 @@
function smallest_prime_factor(number: biginteger): biginteger;
begin
var divisor := 3bi;
repeat
if (number mod divisor) = 0 then
begin
result := divisor;
exit
end;
divisor += 2;
until divisor * divisor > number;
result := number;
end;
function euclid_mullin(): sequence of biginteger;
begin
var product := 2bi;
yield product;
while true do
begin
var smallest_prime := smallest_prime_factor(product + 1);
product *= smallest_prime;
yield smallest_prime;
end;
end;
begin
euclid_mullin.take(16).println;
end.

View file

@ -0,0 +1,58 @@
include Settings
say version; say 'Euclid-Mullin sequence'; say
numeric digits 100
call Task 16
say Format(Time('e'),,3) 'seconds'
exit
Task:
procedure expose eucl.
arg x
say 'The first' x 'Euclid-Mullin numbers are:'
eucl. = 0; eucl.euclid.1 = 2; eucl.0 = 1
p = 2
do i = 2 to x
z = p+1; t = Ffactor(z); eucl.euclid.i = t; p = p*t
end
eucl.0 = x
do i = 1 to x
call charout ,eucl.euclid.i' '
end
say
return x
Ffactor:
/* First prime factor */
procedure
arg x
/* Fast values */
if x < 4 then
return x
/* Check low factors */
n = 0
pr = '2 3 5 7 11 13 17 19 23'
do i = 1 to Words(pr)
p = Word(pr,i)
if x//p = 0 then
return p
end
/* Check higher factors */
do j = 29 by 6 while j*j <= x
p = Right(j,1)
if p <> 5 then
if x//j = 0 then
return j
if p = 3 then
iterate
y = j+2
if x//y = 0 then
return y
end
/* Last factor */
if x > 1 then
return x
return 0
include Functions
include Abend