Euler program (python) Problem 25

Source: Internet
Author: User

1000-digit Fibonacci Numberproblem 25

The Fibonacci sequence is defined by the recurrence relation:

f n = f n? 1 + f n? 2, where F1 = 1 and F2 = 1.

Hence The first terms would be:

F1 = 1
F2 = 1
F3 = 2
F4 = 3
F5 = 5
F6 = 8
F7 = 13
F8 = 21
F9 = 34
F10 = 55
F11 = 89
F12 = 144

The 12th term, F12, are the first term to contain three digits.

What's the index of the first term in the Fibonacci sequence to contain? digits?


Go to the "thread for Problem" in the forum.

Python code:

A,b=0,1count=1while B//pow (10,999) <1:    count+=1    a,b=b,a+bprint (count)

Time : <1s

Euler program (python) Problem 25

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.