Python Forum
Assistance with Fibonacci code
Thread Rating:
  • 2 Vote(s) - 3 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Assistance with Fibonacci code
#4
11 is a very strange number.

Fibonacci is a very strange sequence.

For every Fibonacci sequence of length 10, the sum of the sequence is equal to the 7th term times 11!

As long as you enter 10 in myApp() the sum of the sequence is equal to the 7th term times 11!

def myApp(num):
    if num < 7:
        print("Please enter a number >= 7.")
        return
    one = random.randint(1, 100)
    two = random.randint(1, 100)
    print(f'first number is {one}, the second number is {two}.')
    myfibo = [one, two]
    for n in range(2, num):
        nu = myfibo[n-2] + myfibo[n-1]
        myfibo.append(nu)
    for i in myfibo:
        print(i)
    print(f'the length of myfibo = {len(myfibo)}')
    print(f'The sum of myfibo is {sum(myfibo)}')
    print(f'{myfibo[6]} x 11 = {myfibo[6] * 11}')
    return myfibo
Reply


Messages In This Thread
Assistance with Fibonacci code - by Colombian1976 - Aug-09-2017, 12:21 PM
RE: Assistance with Fibonacci code - by ichabod801 - Aug-09-2017, 01:07 PM
RE: Assistance with Fibonacci code - by Karthikeyan - Feb-16-2024, 04:59 PM
RE: Assistance with Fibonacci code - by Pedroski55 - Feb-17-2024, 12:09 PM

Possibly Related Threads…
Thread Author Replies Views Last Post
  Fibonacci sequence problem is confusing me adam10e10 2 3,562 Apr-04-2019, 10:55 AM
Last Post: perfringo
  Help needed on Fibonacci series nvakada 1 2,512 Apr-25-2018, 07:12 PM
Last Post: micseydel
  Linear Fibonacci sequence Tawnwen 1 3,326 Feb-27-2018, 08:01 AM
Last Post: nilamo
  Help with fibonacci sequence masonmoore93 2 8,051 Oct-01-2017, 12:56 AM
Last Post: masonmoore93
  Fibonacci sequence logic 3 4,813 Jun-11-2017, 08:23 PM
Last Post: Ofnuts

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020