36 lines
662 B
Text
36 lines
662 B
Text
Global.i t = 15, Dim p(t)
|
|
|
|
Procedure.i padovanN(n, Array p(1))
|
|
If n < 2 Or t < 3
|
|
For i = 0 To t - 1
|
|
p(i) = 1
|
|
Next i
|
|
ProcedureReturn
|
|
EndIf
|
|
|
|
padovanN(n - 1, p())
|
|
|
|
For i.i = n + 1 To t - 1
|
|
p(i) = 0
|
|
For j.i = i - 2 To i - n - 1 Step -1
|
|
p(i) = p(i) + p(j)
|
|
Next j
|
|
Next i
|
|
EndProcedure
|
|
|
|
If OpenConsole()
|
|
PrintN("First" + Str(t) + " terms of the Padovan n-step number sequences:")
|
|
For n.i = 2 To 8
|
|
Print(Str(n) + ":")
|
|
|
|
padovanN(n, p())
|
|
|
|
For i.i = 0 To t - 1
|
|
Print(RSet(Str(p(i)),4))
|
|
Next i
|
|
PrintN("")
|
|
Next n
|
|
|
|
PrintN(#CRLF$ + "--- terminado, pulsa RETURN---"): Input()
|
|
CloseConsole()
|
|
EndIf
|