2 Replies - 249 Views - Last Post: 01 May 2013 - 06:48 AM Rate Topic: -----

#1 xxhunt3rzxx  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 1
  • Joined: 01-May 13

python fibonacci

Posted 01 May 2013 - 06:07 AM

im a fresh man how ca i print the fibo sequence and i start in 0 heres my code

while 1:
    c = input("\nenter a number: ")
    num1 = 0
    num2 = 1
    for i in range(c):
        print num2,
        num1=num2-num1
        num2=num2+num1


This post has been edited by jon.kiparsky: 01 May 2013 - 06:44 AM
Reason for edit:: code tags

Is This A Good Question/Topic? 0
  • +

Replies To: python fibonacci

#2 modi123_1  Icon User is online

  • Suitor #2
  • member icon



Reputation: 9195
  • View blog
  • Posts: 34,518
  • Joined: 12-June 08

Re: python fibonacci

Posted 01 May 2013 - 06:47 AM

Typically 'print' works pretty well.
Was This Post Helpful? 0
  • +
  • -

#3 jon.kiparsky  Icon User is online

  • Pancakes!
  • member icon


Reputation: 7737
  • View blog
  • Posts: 13,070
  • Joined: 19-March 11

Re: python fibonacci

Posted 01 May 2013 - 06:48 AM

[me being an idiot deleted]

EDIT: I'm an idiot. No, that works. The only problem is you're not printing the initial seed numbers. You could just print those manually.

This post has been edited by jon.kiparsky: 01 May 2013 - 06:57 AM

Was This Post Helpful? 0
  • +
  • -

Page 1 of 1