2016 Update

This commit is contained in:
Tina Müller 2016-12-05 22:15:40 +01:00
parent 948b86eafa
commit dcf5d15da3
7965 changed files with 139854 additions and 31002 deletions

View file

@ -0,0 +1,26 @@
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

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