r/funny •

Pidgonacci Sequence

[deleted] — view deleted post

0 Upvotes

22k comments sorted by

View all comments

Show parent comment

2

u/0x24a537r9 Jun 10 '12
import os
import sys

a, b, term = 0, 1, 1
start = int(raw_input('Enter the number you want to start with: '))

while (a < start):
  term += 1
  c = a + b
  a = b
  b = c
  print '\n%d: %d' % (term, c)

if a != start:
  print 'Uh oh, your start number is not a Fibonacci number!'
  sys.exit()

while (True):
  term += 1
  c = a + b
  a = b
  b = c
  print '\n%d: %d' % (term, c)
  os.system('echo "%d: %d" | pbcopy' % (term, c))
  raw_input('Press Enter to continue...')