{"id":3017,"date":"2023-02-13T09:58:04","date_gmt":"2023-02-13T01:58:04","guid":{"rendered":"http:\/\/cnliutz.uicp.io\/?p=3017"},"modified":"2023-02-13T09:58:04","modified_gmt":"2023-02-13T01:58:04","slug":"fibonacci%e6%96%90%e6%b3%a2%e9%82%a3%e5%a5%91%e6%95%b0%e5%88%97python%e7%a8%8b%e5%ba%8f","status":"publish","type":"post","link":"http:\/\/g1n29wqq.ipyingshe.net:5347\/?p=3017","title":{"rendered":"Fibonacci\u6590\u6ce2\u90a3\u5951\u6570\u5217python\u7a0b\u5e8f"},"content":{"rendered":"\n<pre class=\"wp-block-code\"><code># Define a function to find the nth Fibonacci number\r\ndef fibonacci(n):\r\n  # Base cases: 0 and 1\r\n  if n == 0:\r\n    return 0\r\n  elif n == 1:\r\n    return 1\r\n  # Recursive case: use the formula F(n) = F(n-1) + F(n-2)\r\n  else:\r\n    return fibonacci(n-1) + fibonacci(n-2)\r\n\r\n# Ask the user for a positive integer\r\nn = int(input(\"Enter a positive integer: \"))\r\n\r\n# Print the Fibonacci sequence up to the nth term\r\nprint(\"The Fibonacci sequence up to the\", n, \"th term is:\")\r\nfor i in range(n):\r\n  print(fibonacci(i), end=\" \")<\/code><\/pre>\n","protected":false},"excerpt":{"rendered":"","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[2],"tags":[],"class_list":["post-3017","post","type-post","status-publish","format-standard","hentry","category-2"],"_links":{"self":[{"href":"http:\/\/g1n29wqq.ipyingshe.net:5347\/index.php?rest_route=\/wp\/v2\/posts\/3017","targetHints":{"allow":["GET"]}}],"collection":[{"href":"http:\/\/g1n29wqq.ipyingshe.net:5347\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"http:\/\/g1n29wqq.ipyingshe.net:5347\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"http:\/\/g1n29wqq.ipyingshe.net:5347\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"http:\/\/g1n29wqq.ipyingshe.net:5347\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=3017"}],"version-history":[{"count":1,"href":"http:\/\/g1n29wqq.ipyingshe.net:5347\/index.php?rest_route=\/wp\/v2\/posts\/3017\/revisions"}],"predecessor-version":[{"id":3018,"href":"http:\/\/g1n29wqq.ipyingshe.net:5347\/index.php?rest_route=\/wp\/v2\/posts\/3017\/revisions\/3018"}],"wp:attachment":[{"href":"http:\/\/g1n29wqq.ipyingshe.net:5347\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=3017"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"http:\/\/g1n29wqq.ipyingshe.net:5347\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=3017"},{"taxonomy":"post_tag","embeddable":true,"href":"http:\/\/g1n29wqq.ipyingshe.net:5347\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=3017"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}