Fibonacci序列 - 如何在C#中编码 [英] Fibonacci Sequence - how to code in C#
本文介绍了Fibonacci序列 - 如何在C#中编码的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我对编码比较陌生,我的一个任务就是在C#中创建一个斐波纳契码。用户输入两个数字并显示输出。序列只能小于或等于200.
提前致谢!
Im relatively new to coding, and one of my tasks is create a fibonacci code in C#. the user inputs two numbers and the output is displayed. the sequence can only be less than or equal to 200.
Thanks in advance!
推荐答案
First用普通类型语言写出来,并将结果转换为C#。类似于:
First write it out in normal type language, and convert the result to C#. Something like:
Let number1 = 0
Let number2 = 1
Print "0"
Print "1"
Let limit = << input from user
While limit > 0
Do
Let sum = number1 + number2
Print sum
Let number1 = number2
Let number2 = sum
Let limit = limit - 1
Done
这篇关于Fibonacci序列 - 如何在C#中编码的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文