Data commit
This commit is contained in:
parent
7387c8f97b
commit
cb5bb5e222
199093 changed files with 3378972 additions and 0 deletions
|
|
@ -0,0 +1,51 @@
|
|||
EnableExplicit
|
||||
Define.i i
|
||||
|
||||
If OpenConsole("")
|
||||
PrintN("Stern-Brocot_sequence")
|
||||
Else
|
||||
End 1
|
||||
EndIf
|
||||
|
||||
Procedure.i f(n.i)
|
||||
If n<2
|
||||
ProcedureReturn n
|
||||
ElseIf n&1
|
||||
ProcedureReturn f(n/2)+f(n/2+1)
|
||||
Else
|
||||
ProcedureReturn f(n/2)
|
||||
EndIf
|
||||
EndProcedure
|
||||
|
||||
Procedure.i gcd(a.i,b.i)
|
||||
If b : ProcedureReturn gcd(b,a%b) : EndIf
|
||||
ProcedureReturn a
|
||||
EndProcedure
|
||||
|
||||
Procedure.i ind(m.i)
|
||||
Define.i i=1
|
||||
While f(i)<>m : i+1 : Wend
|
||||
ProcedureReturn i
|
||||
EndProcedure
|
||||
|
||||
Print("First 15 elements: ")
|
||||
For i=1 To 15
|
||||
Print(Str(f(i))+Space(3))
|
||||
Next
|
||||
PrintN(~"\n")
|
||||
|
||||
For i=1 To 10
|
||||
PrintN(RSet(Str(i),3)+" is at pos. #"+Str(ind(i)))
|
||||
Next
|
||||
PrintN("100 is at pos. #"+Str(ind(100)))
|
||||
PrintN("")
|
||||
|
||||
i=1
|
||||
While i<1000 And gcd(f(i),f(i+1))=1 : i+1 : Wend
|
||||
If i=1000
|
||||
PrintN("All GCDs are 1.")
|
||||
Else
|
||||
PrintN("GCD of "+Str(i)+" and "+Str(i+1)+" is not 1")
|
||||
EndIf
|
||||
|
||||
Input()
|
||||
Loading…
Add table
Add a link
Reference in a new issue