当前位置:网站首页>C#输出斐波那契数列
C#输出斐波那契数列
2022-07-23 05:47:00 【业余幻想家】
一、什么是斐波那契数列
斐波那契数列(Fibonacci sequence),又称黄金分割数列、因数学家列昂纳多·斐波那契(Leonardoda Fibonacci)以兔子繁殖为例子而引入,故又称为“兔子数列”
二、斐波那契数列定义:
简单来说,斐波那契数列指的是形如这样的一个数列 1, 1, 2, 3, 5, 8, 13, 21, 34, 55, 89…
就是数列从数列的第3项开始,每一项都等于前两项之和。
三、使用C#实现斐波那契数列
当我们充分理解了斐波那契数列的定义之后,那么就可以使用编程语言将它实现了(示例选用C#实现输出斐波那契数列,并按5行4列的方式输出)
using System;
namespace fibonacci
{
class Program
{
static void Main(string[] args)
{
int a = 1;
int b = 1;
int c = 0;
Console.WriteLine("斐波那契数列:");
for(int i=1; i<=5; i++)
{
for (int j=1; j<= 4; j++)
{
Console.Write("{0}\t", a);
c = a + b;
a = b;
b = c;
}
Console.WriteLine();
}
Console.ReadKey();
}
}
}
边栏推荐
- Unity3d:assetbundle simulation loading, synchronous loading, asynchronous loading, dependent package loading, automatic labeling, AB browser, incremental packaging
- PPP 配置实例学习记录
- HCIP---HCIA知识回顾(一)
- ftp部署
- HCIP---条件匹配和OSPF协议
- 如何解决if语句太多
- Explain the establishment of TCP connection in detail
- [Reading Notes "Phoenix architecture" - a large-scale distributed system with reliable architecture. Zhou Zhiming] (I)
- 读《凤凰架构》- RPC的历史与知识
- Unity mouse controls camera drag, rotation and zoom (simulation editor camera function)
猜你喜欢

HCIP-第一次实验

Hcip--- BGP related configuration (Federal chapter)

DHCP原理与配置

Hcip --- mGRE comprehensive experiment

HCIP-HCIA知识回顾(二)

Hcip --- HCIA knowledge review (I)

学习日记——(路由与交换技术)网络地址转换 NAT技术

Unity used trilib plug-in under URP pipeline to load model material incorrectly
![[AUTOSAR storage stack NVM]](/img/7a/15e01f8ace647b55e11e764dba1b64.png)
[AUTOSAR storage stack NVM]

FTP 配置实例学习记录
随机推荐
htpasswd作用
Explain various network protocols in detail
PPP 配置实例学习记录
C custom set
Do a Cisco experiment!
HCIP --- HDLC和PPP协议
详解TCP连接的建立
Learning diary - (routing and switching technology) layer 3 switch
Routing and interface technology -- Summary of direct network
es常见操作
手动配置DHCP服务
C: stack stack source code, array stack, chain stack
OSPF comprehensive experiment in hcip-mgre environment
Explain the release of TCP connection in detail
在二叉排序树中删除节点
Design experience of log file IO system
C # custom bidirectional linked list
记一次日志文件IO系统的设计心得
C # custom stack
HCIP---MGRE环境下的OSPF综合实验