Padovan n-step number sequences: Difference between revisions

Added FreeBasic
m (Remove stray redundant header markup)
(Added FreeBasic)
Line 619:
8 | 1 1 1 2 3 5 8 13 21 34 54 87 140 225 362
</pre>
 
=={{header|FreeBASIC}}==
{{trans|C}}
Rosetta Code problem: https://rosettacode.org/wiki/Padovan_n-step_number_sequences
by Jjuanhdez, 05/2023
<syntaxhighlight lang="vb">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
Exit Sub
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</syntaxhighlight>
{{out}}
<pre>First 15 terms of the Padovan n-step number sequences:
2: 1 1 1 2 2 3 4 5 7 9 12 16 21 28 37
3: 1 1 1 2 3 4 6 9 13 19 28 41 60 88 129
4: 1 1 1 2 3 5 7 11 17 26 40 61 94 144 221
5: 1 1 1 2 3 5 8 12 19 30 47 74 116 182 286
6: 1 1 1 2 3 5 8 13 20 32 51 81 129 205 326
7: 1 1 1 2 3 5 8 13 21 33 53 85 136 218 349
8: 1 1 1 2 3 5 8 13 21 34 54 87 140 225 362</pre>
 
=={{header|Go}}==
2,122

edits