File tree Expand file tree Collapse file tree 1 file changed +8
-6
lines changed
Expand file tree Collapse file tree 1 file changed +8
-6
lines changed Original file line number Diff line number Diff line change 11"""
2- This program calculates the "Nth Tribonacci number in a series.
2+ This program calculates the "Nth Tribonacci number in a series.
33
4- The Tribonacci sequence Tn is defined as follows :-
4+ The Tribonacci sequence Tn is defined as follows :-
55
6- T(0) = 0; T(1) = 1; T(2) = 1; and T(n+3) = T(n) + T(n+1) + T(n+3) for n>=0
6+ T(0) = 0; T(1) = 1; T(2) = 1; and T(n+3) = T(n) + T(n+1) + T(n+3) for n>=0
77
8- In this program, we assume an integer 'n' is given and we have to calculate nth Tribinacci number
8+ In this program, we assume an integer 'n' is given and
9+ we have to calculate nth Tribinacci number
910
1011"""
1112
12- def tribonacci (self , n : int ) -> int :
13+ def tribonacci (n : int ) -> int :
1314 trib = [0 ,1 ,1 ]
1415 for i in range (3 ,n + 1 ):
1516 x = trib [i - 1 ] + trib [i - 2 ] + trib [i - 3 ]
@@ -18,4 +19,5 @@ def tribonacci(self, n : int) -> int :
1819
1920
2021if __name__ == "__main__" :
21- print (tribonacci (25 )) #prints 1389537
22+ import doctest
23+ doctest .testmod ()
You can’t perform that action at this time.
0 commit comments