Skip to content

Instantly share code, notes, and snippets.

@Nanich87
Last active January 21, 2024 15:28
Tribonacci
Module Tribonacci
Sub main()
Dim T1 As Integer = Integer.Parse(Console.ReadLine())
Dim T2 As Integer = Integer.Parse(Console.ReadLine())
Dim T3 As Integer = Integer.Parse(Console.ReadLine())
Dim N As Integer = Integer.Parse(Console.ReadLine())
Dim T(N - 1) As Integer
T(0) = T1
T(1) = T2
T(2) = T3
For i As Integer = 3 To N - 1
T(i) = T(i - 3) + T(i - 2) + T(i - 1)
Next i
Console.WriteLine(T(N - 1))
Console.ReadLine()
End Sub
End Module
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment