# I am trying to make a Fibonacci sequence please someone help i have tried every combo i can think of just point me in the right direction no answers

#### Kaleb

here is one of my tries
fibonacci = eval(input("How many times do you want Fibonacci to repeat: "))
for i in range(fibonacci):
print(1+i+i)

#### VBService

print(1+i+i)
Is not exactly that easy

### Guide to the Fibonacci Sequence​

F(n) is used to indicate the number of pairs ..., so the sequence can be expressed like this:

F(0) = 0
F(1) = 1
F(n) = F(n - 1) + F(n - 2)

In mathematical terminology, you’d call this a recurrence relation, meaning that each term of the sequence (beyond 0 and 1) is a function of the preceding terms.

Python:
``````# Ask the user for the number of Fibonacci numbers to generate
how_many = eval(input("How many Fibonacci numbers do you want to generate? "))

# Initialize the first two numbers
a, b = 0, 1

# Print the Fibonacci sequence
for i in range(how_many):
if i == 0:
print(a)
elif i == 1:
print(b)
else:
n = a + b
print(n)
a, b = b, n``````
Python:
``````message = '''
How many Fibonacci numbers do you want to generate?
Enter number greater than 2: '''

# Ask the user for the number of Fibonacci numbers to generate
how_many = eval(input(message))

# Initialize the first two numbers and print
a, b = 0, 1
print("\n", a, "\n", b, sep="")

# Print the Fibonacci sequence
for i in range(how_many - 2):
n = a + b
print(n)
a, b = b, n``````

Last edited:

#### Kaleb

thank you VBService I was about ready to give up on this if not for you

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

### Members online

No members online now.