[GoLUG] The Tribonacci numbers

Steve Litt slitt at troubleshooters.com
Sat May 24 06:37:12 EDT 2025


Hi all,

You've all heard of the Fibonacci numbers, where every number is the
sum of the previous two in the sequence. Here's a program producing the
Tribonacci numbers, in which every number is the sum of the previous
THREE in the sequence:

======================================================
#!/usr/bin/python
me = 1
dad = 1
gramps = 1
son = 0
while son < 1000:
    son = me + dad + gramps
    print(son)
    gramps = dad
    dad = me
    me = son
======================================================


SteveT

Steve Litt 
http://444domains.com



More information about the GoLUG mailing list