September 2017 Update
This commit is contained in:
parent
bba7bfd280
commit
ba8067c3b7
14570 changed files with 153136 additions and 63871 deletions
|
|
@ -0,0 +1,26 @@
|
|||
Procedure.s zeck(n.i)
|
||||
Dim f.i(1) : Define i.i=1, o$
|
||||
f(0)=1 : f(1)=1
|
||||
While f(i)<n
|
||||
i+1 : ReDim f(ArraySize(f())+1) : f(i)=f(i-1)+f(i-2)
|
||||
Wend
|
||||
For i=i To 1 Step -1
|
||||
If n>=f(i) : o$+"1" : n-f(i) : Else : o$+"0" : EndIf
|
||||
Next
|
||||
If Len(o$)>1 : o$=LTrim(o$,"0") : EndIf
|
||||
ProcedureReturn o$
|
||||
EndProcedure
|
||||
|
||||
Define n.i, t$
|
||||
OpenConsole("Zeckendorf number representation")
|
||||
PrintN(~"\tNr.\tZeckendorf")
|
||||
For n=0 To 20
|
||||
t$=zeck(n)
|
||||
If FindString(t$,"11")
|
||||
PrintN("Error: n= "+Str(n)+~"\tZeckendorf= "+t$)
|
||||
Break
|
||||
Else
|
||||
PrintN(~"\t"+RSet(Str(n),3," ")+~"\t"+RSet(t$,7," "))
|
||||
EndIf
|
||||
Next
|
||||
Input()
|
||||
Loading…
Add table
Add a link
Reference in a new issue