40 lines
735 B
Text
40 lines
735 B
Text
' Rosetta Code problem: https://rosettacode.org/wiki/Padovan_n-step_number_sequences
|
|
' by Jjuanhdez, 05/2023
|
|
|
|
Const t = 15
|
|
Dim Shared As Integer p(t)
|
|
|
|
Sub padovanN(n As Integer, p() As Integer)
|
|
Dim As Integer i, j
|
|
|
|
If n < 2 Or t < 3 Then
|
|
For i = 0 To t-1
|
|
p(i) = 1
|
|
Next i
|
|
Exit Sub
|
|
End If
|
|
|
|
padovanN(n-1, p())
|
|
|
|
For i = n + 1 To t-1
|
|
p(i) = 0
|
|
For j = i - 2 To i-n-1 Step -1
|
|
p(i) += p(j)
|
|
Next j
|
|
Next i
|
|
End Sub
|
|
|
|
Print "First"; t; " terms of the Padovan n-step number sequences:"
|
|
Dim As Integer n, i
|
|
For n = 2 To 8
|
|
Print n; ": ";
|
|
|
|
padovanN(n, p())
|
|
|
|
For i = 0 To t-1
|
|
Print Using "### "; p(i);
|
|
Next i
|
|
Print
|
|
Next n
|
|
|
|
Sleep
|