Skip to content

Commit fd1abd8

Browse files
[pre-commit.ci] auto fixes from pre-commit.com hooks
for more information, see https://pre-commit.ci
1 parent 76529e1 commit fd1abd8

File tree

1 file changed

+11
-10
lines changed

1 file changed

+11
-10
lines changed

maths/tribonacci.py

Lines changed: 11 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,22 @@
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 we have to calculate nth Tribinacci number
99
1010
"""
1111

12-
def tribonacci(self, n : int) -> int :
13-
trib = [0,1,1]
14-
for i in range(3,n+1):
15-
x = trib[i-1] + trib[i-2] + trib[i-3]
12+
13+
def tribonacci(self, n: int) -> int:
14+
trib = [0, 1, 1]
15+
for i in range(3, n + 1):
16+
x = trib[i - 1] + trib[i - 2] + trib[i - 3]
1617
trib.append(x)
1718
return trib[n]
1819

1920

20-
if __name__ == "__main__" :
21-
print(tribonacci(25)) #prints 1389537
21+
if __name__ == "__main__":
22+
print(tribonacci(25)) # prints 1389537

0 commit comments

Comments
 (0)