-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
12 changed files
with
497 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
30 changes: 30 additions & 0 deletions
30
...teu/First number k such that k + a(i) has n distinct prime factors, for all i < n/prog.sf
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
#!/usr/bin/ruby | ||
|
||
# a(n) is the first number k such that k + a(i) has n distinct prime factors, for all i < n; a(0) = 0. | ||
# https://oeis.org/A?????? | ||
|
||
# Known terms: | ||
# 0, 2, 10, 130, 8930, 1133900, 401424520 | ||
|
||
func a(n) is cached { | ||
|
||
return 0 if (n == 0); | ||
var terms = (^n -> map(a).flip) | ||
|
||
var lo = 1 | ||
var hi = 2*lo | ||
|
||
loop { | ||
n.omega_primes_each(lo, hi, {|k| | ||
if (terms.all { is_omega_prime(k + _, n) }) { | ||
return k | ||
} | ||
}) | ||
lo = hi+1 | ||
hi = 2*lo | ||
} | ||
} | ||
|
||
for n in (1..10) { | ||
say [n, a(n)] | ||
} |
101 changes: 101 additions & 0 deletions
101
...er k such that k + a(i) is the product of n distinct prime factors, for all i < n/prog.pl
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,101 @@ | ||
#!/usr/bin/perl | ||
|
||
# a(n) is the first number k such that k + a(i) is the product of n distinct prime factors, for all i < n; a(0) = 0. | ||
# https://oeis.org/A?????? | ||
|
||
# Known terms: | ||
# 0, 2, 33, 1309, 55165, 13386021, 2239003921 | ||
|
||
# Lower-bounds: | ||
# a(7) > 1649267441663, if it exists. | ||
|
||
use 5.036; | ||
use ntheory qw(:all); | ||
|
||
my @terms = (0, 2, 33, 1309, 55165, 13386021, 2239003921); | ||
|
||
sub squarefree_almost_prime_numbers ($A, $B, $k, $callback) { | ||
|
||
$A = vecmax($A, powint(2, $k)); | ||
|
||
my $n = $k; | ||
|
||
sub ($m, $p, $k) { | ||
|
||
if ($k == 1) { | ||
|
||
my $v; | ||
|
||
forprimes { | ||
|
||
$v = $m * $_; | ||
|
||
if ( is_almost_prime($n, $v + $terms[-1]) | ||
and is_almost_prime($n, $v + $terms[-2]) | ||
and is_almost_prime($n, $v + $terms[-3]) | ||
and is_square_free($v + $terms[-1]) | ||
and is_square_free($v + $terms[-2]) | ||
and is_square_free($v + $terms[-3]) | ||
and vecall { is_almost_prime($n, $v + $_) and is_square_free($v + $_) } @terms) { | ||
$callback->($v); | ||
$B = $v if ($v < $B); | ||
lastfor; | ||
} | ||
|
||
} vecmax($p, cdivint($A, $m)), divint($B, $m); | ||
|
||
return; | ||
} | ||
|
||
my $s = rootint(divint($B, $m), $k); | ||
|
||
foreach my $q (@{primes($p, $s)}) { | ||
__SUB__->($m * $q, $q+1, $k - 1); | ||
} | ||
} | ||
->(1, 2, $k); | ||
} | ||
|
||
my $n = 7; | ||
my $lo = 2; | ||
my $hi = 2 * $lo; | ||
|
||
say "\n:: Searching for a($n)\n"; | ||
|
||
while (1) { | ||
|
||
say "Sieving: [$lo, $hi]"; | ||
|
||
my @terms; | ||
squarefree_almost_prime_numbers( | ||
$lo, $hi, $n, | ||
sub($k) { | ||
say "Found upper-bound: a($n) <= $k"; | ||
push @terms, $k; | ||
} | ||
); | ||
|
||
@terms = sort { $a <=> $b } @terms; | ||
|
||
if (@terms) { | ||
say "New term: a($n) = $terms[0]\n"; | ||
last; | ||
} | ||
|
||
$lo = $hi + 1; | ||
$hi = 2 * $lo; | ||
} | ||
|
||
__END__ | ||
Sieving: [805306367, 1610612734] | ||
Sieving: [1610612735, 3221225470] | ||
Found upper-bound: a(6) <= 2239003921 | ||
New term: a(6) = 2239003921 | ||
perl prog.pl 28.40s user 0.04s system 92% cpu 30.751 total | ||
Sieving: [824633720831, 1649267441662] | ||
Sieving: [1649267441663, 3298534883326] | ||
^C | ||
perl prog.pl 6250.60s user 14.21s system 84% cpu 2:03:41.07 total |
30 changes: 30 additions & 0 deletions
30
...er k such that k + a(i) is the product of n distinct prime factors, for all i < n/prog.sf
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
#!/usr/bin/ruby | ||
|
||
# a(n) is the first number k such that k + a(i) is the product of n distinct prime factors, for all i < n; a(0) = 0. | ||
# https://oeis.org/A?????? | ||
|
||
# Known terms: | ||
# 0, 2, 33, 1309, 55165, 13386021, 2239003921 | ||
|
||
func a(n) is cached { | ||
|
||
return 0 if (n == 0); | ||
var terms = (^n -> map(a).flip) | ||
|
||
var lo = 1 | ||
var hi = 2*lo | ||
|
||
loop { | ||
n.squarefree_almost_primes_each(lo, hi, {|k| | ||
if (terms.all { is_squarefree_almost_prime(k + _, n) }) { | ||
return k | ||
} | ||
}) | ||
lo = hi+1 | ||
hi = 2*lo | ||
} | ||
} | ||
|
||
for n in (1..10) { | ||
say "a(#{n}) = #{a(n)}" | ||
} |
30 changes: 30 additions & 0 deletions
30
... that the concatenation of a(i) and k has n distinct prime factors, for all i < n/prog.sf
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
#!/usr/bin/ruby | ||
|
||
# a(n) is the irst number k such that the concatenation of a(i) and k has n distinct prime factors, for all i < n; a(0) = 0. | ||
# https://oeis.org/A?????? | ||
|
||
# Known terms: | ||
# 0, 2, 6, 66, 210, 22110, 9958740 | ||
|
||
func a(n) is cached { | ||
|
||
return 0 if (n == 0); | ||
var terms = (^n -> map(a).flip) | ||
|
||
var lo = 1 | ||
var hi = 2*lo | ||
|
||
loop { | ||
n.omega_primes_each(lo, hi, {|k| | ||
if (terms.all { is_omega_prime(Num(join('', _, k)), n) }) { | ||
return k | ||
} | ||
}) | ||
lo = hi+1 | ||
hi = 2*lo | ||
} | ||
} | ||
|
||
for n in (1..10) { | ||
say "a(#{n}) = #{a(n)}" | ||
} |
30 changes: 30 additions & 0 deletions
30
...ation of a(i) and k has n prime factors, counted with multiplicity, for all i < n/prog.sf
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
#!/usr/bin/ruby | ||
|
||
# a(n) is the irst number k such that the concatenation of a(i) and k has n prime factors, counted with multiplicity, for all i < n; a(0) = 0. | ||
# https://oeis.org/A?????? | ||
|
||
# Known terms: | ||
# 0, 2, 6, 8, 152, 920, 2256, 57824, 223520, 612500, 14103168, 110125568 | ||
|
||
func a(n) is cached { | ||
|
||
return 0 if (n == 0); | ||
var terms = (^n -> map(a).flip) | ||
|
||
var lo = 1 | ||
var hi = 2*lo | ||
|
||
loop { | ||
n.almost_primes_each(lo, hi, {|k| | ||
if (terms.all { is_almost_prime(Num(join('', _, k)), n) }) { | ||
return k | ||
} | ||
}) | ||
lo = hi+1 | ||
hi = 2*lo | ||
} | ||
} | ||
|
||
for n in (1..100) { | ||
say "a(#{n}) = #{a(n)}" | ||
} |
30 changes: 30 additions & 0 deletions
30
... that the concatenation of k and a(i) has n distinct prime factors, for all i < n/prog.sf
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
#!/usr/bin/ruby | ||
|
||
# a(n) is the irst number k such that the concatenation of k and a(i) has n distinct prime factors, for all i < n; a(0) = 1. | ||
# https://oeis.org/A?????? | ||
|
||
# Known terms: | ||
# 1, 3, 14, 804, 48330, 16579170 | ||
|
||
func a(n) is cached { | ||
|
||
return 1 if (n == 0); | ||
var terms = (^n -> map(a).flip) | ||
|
||
var lo = 1 | ||
var hi = 2*lo | ||
|
||
loop { | ||
n.omega_primes_each(lo, hi, {|k| | ||
if (terms.all { is_omega_prime(Num(join('', k, _)), n) }) { | ||
return k | ||
} | ||
}) | ||
lo = hi+1 | ||
hi = 2*lo | ||
} | ||
} | ||
|
||
for n in (1..10) { | ||
say "a(#{n}) = #{a(n)}" | ||
} |
30 changes: 30 additions & 0 deletions
30
...ation of k and a(i) has n prime factors, counted with multiplicity, for all i < n/prog.sf
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
#!/usr/bin/ruby | ||
|
||
# a(n) is the irst number k such that the concatenation of k and a(i) has n prime factors, counted with multiplicity, for all i < n; a(0) = 1. | ||
# https://oeis.org/A?????? | ||
|
||
# Known terms: | ||
# 1, 3, 9, 555, 18762, 1516626 | ||
|
||
func a(n) is cached { | ||
|
||
return 1 if (n == 0); | ||
var terms = (^n -> map(a).flip) | ||
|
||
var lo = 1 | ||
var hi = 2*lo | ||
|
||
loop { | ||
n.almost_primes_each(lo, hi, {|k| | ||
if (terms.all { is_almost_prime(Num(join('', k, _)), n) }) { | ||
return k | ||
} | ||
}) | ||
lo = hi+1 | ||
hi = 2*lo | ||
} | ||
} | ||
|
||
for n in (1..100) { | ||
say "a(#{n}) = #{a(n)}" | ||
} |
52 changes: 52 additions & 0 deletions
52
...-research/J.W.L. (Jan) Eerland/Smallest k such that 3^(4*3^n) - k is a safe prime/prog.sf
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,52 @@ | ||
#!/usr/bin/ruby | ||
|
||
# Smallest k such that 3^(4*3^n) - k is a safe prime. | ||
# https://oeis.org/A376946 | ||
|
||
# Known terms: | ||
# 22, 202, 6934, 634, 109678, 445294, 2323138 | ||
|
||
# Lower-bounds: | ||
# a(7) > 23348433 | ||
|
||
func a(n, from=1) { | ||
|
||
var prefix = 3**(4 * 3**n) | ||
var len = prefix.len | ||
|
||
for k in (from .. Inf) { | ||
say "Testing: #{k} (length: #{len})" | ||
|
||
local Num!USE_PFGW = false | ||
|
||
if (primality_pretest(prefix - k) && primality_pretest((prefix - k - 1)>>1)) { | ||
|
||
local Num!USE_PFGW = true | ||
|
||
if (prefix - k -> is_safe_prime) { | ||
return k | ||
} | ||
} | ||
} | ||
} | ||
|
||
var n = 7 | ||
var from = 23348433 | ||
|
||
say "a(#{n}) = #{a(n, from)}" | ||
|
||
#for n in (0..100) { | ||
# say [n, a(n)] | ||
#} | ||
|
||
__END__ | ||
[0, 22] | ||
[2, 6934] | ||
[3, 634] | ||
[4, 109678] | ||
[5, 445294] | ||
[6, 2323138] | ||
|
||
Testing: 14194858 (length: 4174) | ||
^C | ||
/home/swampyx/Other/Programare/sidef/bin/sidef -N prog.sf 20260.40s user 1064.73s system 95% cpu 6:13:50.82 total |
Oops, something went wrong.