您的位置:首页 > 编程语言 > C#

[C#]第30位数字是多少

2016-03-26 13:26 267 查看
/*问题描述:一系列数的规则如下:1 1 2 3 5 8……求第三十位数字是多少
*/
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace ConsoleApplication1
{
class Program
{
static void Main(string[] args)
{
int x = 1, y = 1;
int count = 2;
while (count < 30)
{
int z = x + y;
x = y;
y = z;
++count;
}
Console.WriteLine("第30位的数值是:{0}", y);
Console.ReadKey();
}
}
}

运行结果:

内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: