LoginSignup
1
0

More than 3 years have passed since last update.

【初心者】pythonで0から Project Euler を解いてみた25

Posted at

今回は、Euler25を解いていくっ!!!!
問題はここっ!!!
http://odz.sakura.ne.jp/projecteuler/index.php?cmd=read&page=Problem%2025
フィボナッチ数列ですねーーー
なんか最初のほうに似た問題ありましたね

コード

Fn = [1,1]
ter = 0
while True:
    Fn.append(Fn[ter] + Fn[ter+1])
    ter += 1
    if Fn[ter+1] > 10 ** 999:
        break
print(Fn)
print(len(Fn))

今回はリスト使ったらうまくできるんじゃねと思いリストを使いやりました
まず最初に問題で定義されていた[1,1]から始めました
そして作った数をリストに追加していくことにして解きました
かなり簡単できたんじゃかなと思いました:two_hearts:

1
0
2

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
1
0