Initial data commit
This commit is contained in:
parent
72d218235f
commit
f23f22d71c
199087 changed files with 3378941 additions and 0 deletions
26
Task/Recamans-sequence/PureBasic/recamans-sequence.basic
Normal file
26
Task/Recamans-sequence/PureBasic/recamans-sequence.basic
Normal file
|
|
@ -0,0 +1,26 @@
|
|||
#MAX=500000
|
||||
Dim a.i(#MAX)
|
||||
Dim b.b(1)
|
||||
Dim c.b(1000)
|
||||
FillMemory(@c(),1000,1,#PB_Byte)
|
||||
|
||||
If OpenConsole() : Else : End 1 : EndIf
|
||||
For n_Count=0 To #MAX
|
||||
If n_Count=0
|
||||
a(n_Count)=0
|
||||
ElseIf a(n_Count-1)-n_Count>0 And b(a(n_Count-1)-n_Count)=0
|
||||
a(n_Count)=a(n_Count-1)-n_Count
|
||||
Else
|
||||
a(n_Count)=a(n_Count-1)+n_Count
|
||||
EndIf
|
||||
If ArraySize(b())<a(n_Count) : ReDim b(a(n_Count)) : EndIf
|
||||
If b(a(n_Count))=1 And fitD=0 : fitD=n_Count : EndIf
|
||||
b(a(n_Count))=1
|
||||
If CompareMemory(@b(),@c(),1000) And fit1000=0 : fit1000=n_Count : Break : EndIf
|
||||
Next
|
||||
|
||||
Print("First 15 terms: ") : For i=0 To 14 : Print(RSet(Str(a(i)),4)) : Next : PrintN("")
|
||||
PrintN("First duplicate term : a("+Str(fitD)+") = "+Str(a(fitD)))
|
||||
PrintN("Number of Recaman terms needed to generate all integers from [0..1000]: "+Str(fit1000))
|
||||
Input()
|
||||
End
|
||||
Loading…
Add table
Add a link
Reference in a new issue