Data update

This commit is contained in:
Ingy döt Net 2026-02-01 16:33:20 -08:00
parent 5150844a7d
commit 4bb20c9b71
7735 changed files with 38060 additions and 199180 deletions

View file

@ -22,29 +22,14 @@ PROC to zeckendorf = ( INT n )STRING:
f pos -:= 1
OD;
# if we found a digit, build the representation #
IF f pos >= LWB fibonacci THEN
# have a digit #
BOOL skip digit := FALSE;
WHILE f pos >= LWB fibonacci DO
IF rest <= 0 THEN
result +:= "0"
ELIF skip digit THEN
# we used the previous digit #
skip digit := FALSE;
result +:= "0"
ELIF rest < fibonacci[ f pos ] THEN
# can't use the digit at f pos #
skip digit := FALSE;
result +:= "0"
ELSE
# can use this digit #
skip digit := TRUE;
result +:= "1";
rest -:= fibonacci[ f pos ]
FI;
f pos -:= 1
OD
FI;
FOR f FROM f pos BY -1 TO LWB fibonacci DO
IF rest < fibonacci[ f ] THEN
result +:= "0"
ELSE
result +:= "1";
rest -:= fibonacci[ f ]
FI
OD;
IF rest = 0 THEN
# found a representation #
result

View file

@ -1,26 +0,0 @@
with Ada.Text_IO, Ada.Strings.Unbounded;
procedure Print_Zeck is
function Zeck_Increment(Z: String) return String is
begin
if Z="" then
return "1";
elsif Z(Z'Last) = '1' then
return Zeck_Increment(Z(Z'First .. Z'Last-1)) & '0';
elsif Z(Z'Last-1) = '0' then
return Z(Z'First .. Z'Last-1) & '1';
else -- Z has at least two digits and ends with "10"
return Zeck_Increment(Z(Z'First .. Z'Last-2)) & "00";
end if;
end Zeck_Increment;
use Ada.Strings.Unbounded;
Current: Unbounded_String := Null_Unbounded_String;
begin
for I in 1 .. 20 loop
Current := To_Unbounded_String(Zeck_Increment(To_String(Current)));
Ada.Text_IO.Put(To_String(Current) & " ");
end loop;
end Print_Zeck;

View file

@ -1,19 +1,19 @@
Z: function [x][
if x=0 -> return "0"
fib: new [2 1]
fib: [2 1]
n: new x
while -> n > first fib
-> insert 'fib 0 fib\0 + fib\1
result: new ""
result: ""
loop fib 'f [
if? f =< n [
switch f =< n [
'result ++ "1"
'n - f
]
else -> 'result ++ "0"
-> 'result ++ "0"
]
if result\0 = `0` ->
if result\0 = '0' ->
result: slice result 1 (size result)-1
return result
]

View file

@ -1,42 +0,0 @@
For $i = 0 To 20
ConsoleWrite($i &": "& Zeckendorf($i)&@CRLF)
Next
Func Zeckendorf($int, $Fibarray = "")
If Not IsArray($Fibarray) Then $Fibarray = Fibonacci($int)
Local $ret = ""
For $i = UBound($Fibarray) - 1 To 1 Step -1
If $Fibarray[$i] > $int And $ret = "" Then ContinueLoop ; dont use Leading Zeros
If $Fibarray[$i] > $int Then
$ret &= "0"
Else
If StringRight($ret, 1) <> "1" Then
$ret &= "1"
$int -= $Fibarray[$i]
Else
$ret &= "0"
EndIf
EndIf
Next
If $ret = "" Then $ret = "0"
Return $ret
EndFunc ;==>Zeckendorf
Func Fibonacci($max)
$AList = ObjCreate("System.Collections.ArrayList")
$AList.add("0")
$current = 0
While True
If $current > 1 Then
$count = $AList.Count
$current = $AList.Item($count - 1)
$current = $current + $AList.Item($count - 2)
Else
$current += 1
EndIf
$AList.add($current)
If $current > $max Then ExitLoop
WEnd
$Array = $AList.ToArray
Return $Array
EndFunc ;==>Fibonacci

View file

@ -52,12 +52,12 @@ extension op
}
}
public program()
public Program()
{
for(int i := 1; i <= 20; i += 1)
{
console.printFormatted("{0} : {1}",i,i.zeckendorf()).writeLine()
Console.printFormatted("{0} : {1}",i,i.zeckendorf()).writeLine()
};
console.readChar()
Console.readChar()
}

View file

@ -1,26 +0,0 @@
function Get-ZeckendorfNumber ( $N )
{
# Calculate relevant portation of Fibonacci series
$Fib = @( 1, 1 )
While ( $Fib[-1] -lt $N ) { $Fib += $Fib[-1] + $Fib[-2] }
# Start with 0
$ZeckendorfNumber = 0
# For each number in the relevant portion of Fibonacci series
For ( $i = $Fib.Count - 1; $i -gt 0; $i-- )
{
# If Fibonacci number is less than or equal to remainder of N
If ( $Fib[$i] -le $N )
{
# Double Z number and add 1 (equivalent to adding a '1' to the end of a binary number)
$ZeckendorfNumber = $ZeckendorfNumber * 2 + 1
# Reduce N by Fibonacci number, skip next Fibonacci number
$N -= $Fib[$i--]
}
# If were aren't finished yet, double Z number
# (equivalent to adding a '0' to the end of a binary number)
If ( $i ) { $ZeckendorfNumber *= 2 }
}
return $ZeckendorfNumber
}

View file

@ -1,2 +0,0 @@
# Get Zeckendorf numbers through 20, convert to binary for display
0..20 | ForEach { [convert]::ToString( ( Get-ZeckendorfNumber $_ ), 2 ) }

View file

@ -1,25 +0,0 @@
Function Zeckendorf(n)
num = n
Set fibonacci = CreateObject("System.Collections.Arraylist")
fibonacci.Add 1 : fibonacci.Add 2
i = 1
Do While fibonacci(i) < num
fibonacci.Add fibonacci(i) + fibonacci(i-1)
i = i + 1
Loop
tmp = ""
For j = fibonacci.Count-1 To 0 Step -1
If fibonacci(j) <= num And (tmp = "" Or Left(tmp,1) <> "1") Then
tmp = tmp & "1"
num = num - fibonacci(j)
Else
tmp = tmp & "0"
End If
Next
Zeckendorf = CLng(tmp)
End Function
'testing the function
For k = 0 To 20
WScript.StdOut.WriteLine k & ": " & Zeckendorf(k)
Next