{"title":"如何使用斐波那契数来教递归编程","authors":"J. Gerhard","doi":"10.5206/mt.v1i1.14038","DOIUrl":null,"url":null,"abstract":"There are too many examples and programming guides (which, e.g., an internet search for \"recursive procedure Fibonacci\" will turn up) to count that use Fibonacci numbers as an example to illustrate recursive programming. The motivation for this article is to show why the naive way of doing this is a bad idea, as it is horrendously inefficient. We will exhibit much more efficient ways of computing Fibonacci numbers, both iterative and recursive, and analyze and compare worst case running times and memory usages. Using some mathematical properties of Fibonacci numbers leads to the most efficient method for their computation. For illustration and benchmarking, we will use Maple and its programming language, however, similar behaviour can be demonstrated in almost any other programming language. This exposition combines and explores the mathematical properties of Fibonacci numbers, notions of algorithmic complexity, and efficient Maple programming and profiling techniques, and may be used as an introduction to any of these three subjects. The techniques described can be readily generalized to more general types of linear recurrences with constant coefficients.","PeriodicalId":355724,"journal":{"name":"Maple Transactions","volume":"43 1","pages":"0"},"PeriodicalIF":0.0000,"publicationDate":"2021-10-06","publicationTypes":"Journal Article","fieldsOfStudy":null,"isOpenAccess":false,"openAccessPdf":"","citationCount":"0","resultStr":"{\"title\":\"How to use Fibonacci numbers to teach recursive programming\",\"authors\":\"J. Gerhard\",\"doi\":\"10.5206/mt.v1i1.14038\",\"DOIUrl\":null,\"url\":null,\"abstract\":\"There are too many examples and programming guides (which, e.g., an internet search for \\\"recursive procedure Fibonacci\\\" will turn up) to count that use Fibonacci numbers as an example to illustrate recursive programming. The motivation for this article is to show why the naive way of doing this is a bad idea, as it is horrendously inefficient. We will exhibit much more efficient ways of computing Fibonacci numbers, both iterative and recursive, and analyze and compare worst case running times and memory usages. Using some mathematical properties of Fibonacci numbers leads to the most efficient method for their computation. For illustration and benchmarking, we will use Maple and its programming language, however, similar behaviour can be demonstrated in almost any other programming language. This exposition combines and explores the mathematical properties of Fibonacci numbers, notions of algorithmic complexity, and efficient Maple programming and profiling techniques, and may be used as an introduction to any of these three subjects. The techniques described can be readily generalized to more general types of linear recurrences with constant coefficients.\",\"PeriodicalId\":355724,\"journal\":{\"name\":\"Maple Transactions\",\"volume\":\"43 1\",\"pages\":\"0\"},\"PeriodicalIF\":0.0000,\"publicationDate\":\"2021-10-06\",\"publicationTypes\":\"Journal Article\",\"fieldsOfStudy\":null,\"isOpenAccess\":false,\"openAccessPdf\":\"\",\"citationCount\":\"0\",\"resultStr\":null,\"platform\":\"Semanticscholar\",\"paperid\":null,\"PeriodicalName\":\"Maple Transactions\",\"FirstCategoryId\":\"1085\",\"ListUrlMain\":\"https://doi.org/10.5206/mt.v1i1.14038\",\"RegionNum\":0,\"RegionCategory\":null,\"ArticlePicture\":[],\"TitleCN\":null,\"AbstractTextCN\":null,\"PMCID\":null,\"EPubDate\":\"\",\"PubModel\":\"\",\"JCR\":\"\",\"JCRName\":\"\",\"Score\":null,\"Total\":0}","platform":"Semanticscholar","paperid":null,"PeriodicalName":"Maple Transactions","FirstCategoryId":"1085","ListUrlMain":"https://doi.org/10.5206/mt.v1i1.14038","RegionNum":0,"RegionCategory":null,"ArticlePicture":[],"TitleCN":null,"AbstractTextCN":null,"PMCID":null,"EPubDate":"","PubModel":"","JCR":"","JCRName":"","Score":null,"Total":0}
How to use Fibonacci numbers to teach recursive programming
There are too many examples and programming guides (which, e.g., an internet search for "recursive procedure Fibonacci" will turn up) to count that use Fibonacci numbers as an example to illustrate recursive programming. The motivation for this article is to show why the naive way of doing this is a bad idea, as it is horrendously inefficient. We will exhibit much more efficient ways of computing Fibonacci numbers, both iterative and recursive, and analyze and compare worst case running times and memory usages. Using some mathematical properties of Fibonacci numbers leads to the most efficient method for their computation. For illustration and benchmarking, we will use Maple and its programming language, however, similar behaviour can be demonstrated in almost any other programming language. This exposition combines and explores the mathematical properties of Fibonacci numbers, notions of algorithmic complexity, and efficient Maple programming and profiling techniques, and may be used as an introduction to any of these three subjects. The techniques described can be readily generalized to more general types of linear recurrences with constant coefficients.