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,48 @@
include "NSLog.incl"
_thereIsHope = _true
nsLogSetTitle(@"Curzon numbers in Futurebasic")
NumberFormatterRef form : form = fn NumberFormatterInit
NumberFormatterSetPositiveFormat( form, @"#,###,###" )
local fn comma( n as uint32, pad as byte )as CFStringRef
CFStringRef s = fn NumberFormatterStringFromNumber( form,¬
fn NumberWithInteger( n ) )
end fn = fn StringWithFormat(@"%@%@", right(@" ", pad-len(s)), s)
local fn powMod(b as uint64, p as uint64, m as uint64) as uint64
uint64 x = 1
while p
if (p & 1) then x = (x * b) % m
b = (b * b) % m
p = p >> 1
wend
end fn = x
local fn curzon
CFStringRef s
uint64 k, n, kn1, count
for k = 2 to 12 step 2
n = 1 : count = 0 : kn1 = k * n + 1 : s = @""
NSLog( @"\n First 50 Curzon numbers with base = %d:", k )
while _thereIsHope
if fn powMod(k, n, kn1) + 1 == kn1
count ++
select count
case <= 50 : s = fn StringWithFormat(@"%@%@", s, fn comma(n, 7))
if (count Mod 10) = 0 Then s = fn StringWithFormat(@"%@\n", s)
case 1000 : nslog( @"%@ 1,000th: %@", s, fn comma(n, 0))
break
end select
end if
n++ : kn1 += k
wend
next
end fn
fn curzon
handleevents

View file

@ -0,0 +1,27 @@
##
function isCurzon(n: integer; k: biginteger) := (Power(k, n) + 1) mod (k * n + 1) = 0;
function curzonnumbers(k: integer): sequence of integer;
begin
var n := 1;
while true do
begin
if iscurzon(n, k) then yield n;
n += 1;
end;
end;
foreach var k in |2, 4, 6, 8, 10| do
begin
var i := 1;
println('Curzonnumbers with base', k);
foreach var n in curzonnumbers(k) do
begin
Write(n:5);
if (i mod 10) = 0 then println;
if i = 50 then break;
i += 1;
end;
println('1000th Curzon number', curzonnumbers(k).Skip(999).First);
println;
end;