In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-03-31 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >
Share
Shulou(Shulou.com)06/03 Report--
This article mainly explains "how to use Fibonacci numbers". The content of the explanation is simple and clear, and it is easy to learn and understand. Please follow the editor's train of thought to study and learn "how to use Fibonacci numbers".
Problem description
Fibonacci numbers, also known as Fibonacci series, refer to such a series: 1, 1, 2, 3, 5, 8, 13, 21, …... This series starts with the third term, and each term is equal to the sum of the first two terms. Find the minimum Fibonacci number that is greater than the input number.
Enter: enter a positive integer n (n > = 10) on one line.
Output: output the minimum Fibonacci number greater than n on one line.
Input sample: 10
Sample output: 13
Solution
The generator, the python language, is used first. Generator definition: a function that uses yield is called a generator. In the process of calling the generator to run, the function pauses and saves all the current running information each time it encounters yield, returns the value of yield, and continues to run from the current location the next time the next () method is executed. Use the generator to get the Fibonacci series, and then display the series as a list. Compare the numbers in the series with the integers entered, filter out the numbers that meet the criteria, and then create a new list to put the numbers that meet the criteria. Finally, print out the first element of the new list, that is, the minimum Fibonacci number that meets the criteria!
Thank you for your reading. the above is the content of "how to use Fibonacci numbers". After the study of this article, I believe you have a deeper understanding of how to use Fibonacci numbers, and the specific use needs to be verified in practice. Here is, the editor will push for you more related knowledge points of the article, welcome to follow!
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 218
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.