ã¯ããã« ä»åã¯ããã£ããããæ°å1ã®ä»»æã®é
ãå¾ãé¢æ°ã«ã¤ãã¦èª¿æ»ã»èå¯ãã¦ã¿ã¾ããã ããããããã£ããããæ°åãã¨ã¯ï¼ 以ä¸ã®æ¼¸åå¼ã§è¡¨ãããæ°åã§ãã \[\eqalign{ f(0) &= 0 \\ f(1) &= 1 \\ f(n+2) &= f(n+1) + f(n) \\ }\] ããã§ã¯ä¸è¬é
ã â0çªç®â ããé ã« 0, 1, 1, 2, 3, 5, 8, 13, 21, 34, ⦠ã¨èãã¾ãããã®æ°åã®ç¬¬ n é
ã®å¤ãå¾ãããã°ã©ã ãèãã¦ããããã¨æãã¾ãã ãã£ããããæ°åã®ç¬¬né
ãå¾ãããã°ã©ã ã®ä¾ (1) ã·ã³ãã«ãªå帰å¼ã³åºã å帰å¼ã³åºããç¨ãããæãã·ã³ãã«ãªä¾ãæ¸ãã¦ã¿ã¾ããã # # 01_simple.rb # def fibonacci_simple( n ) case n when 0, 1 return n else return fibo
{{#tags}}- {{label}}
{{/tags}}