博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
32位系统能够识别多达内存_C ++程序可打印多达N个术语的卢卡斯系列
阅读量:2534 次
发布时间:2019-05-11

本文共 1596 字,大约阅读时间需要 5 分钟。

32位系统能够识别多达内存

Given N and we have to print lucas series upto N terms.

给定N,我们必须打印lucas系列,最多N个术语。

卢卡斯系列 (Lucas series)

The Lucas series is an integer series very similar to the Fibonacci series, named after the French mathematician . Each term of the Lucas series is defined as the sum of the previous two terms of the series with the first two terms being 2 and 1 respectively. The Lucas series and Fibonacci series are complementary to each other. The terms of the series are integer powers of the golden ratio rounded to the closest whole number. Given below is the code to find the Terms of the Lucas series up to n iterations.

Lucas系列是一个非常类似于Fibonacci系列的整数系列,该系列以法国数学家名字命名。 Lucas系列的每一项定义为系列的前两项的总和,前两项分别为2和1。 卢卡斯系列和斐波那契系列彼此互补。 该系列的术语是黄金比例的整数幂,四舍五入到最接近的整数。 下面给出的代码可查找最多n次迭代的Lucas系列术语

Code

/*Program to print the Lucas series for n terms.*/#include 
using namespace std;int main(){
int n, i, t1 = 2, t2 = 1, tn; cout << "Enter the number of terms desired in the lucas series: "; cin >> n; if (n == 1) cout << endl << 2 << endl; else if (n == 2) cout << endl << 2 << endl << 1 << endl; else if (n > 2) {
cout <
<<"Lucas series for "<< n<< " terms is:"<
<< t1 << endl << t2 << endl; for (i = 0; i < n-2; i++) {
tn = t1 + t2; cout << tn << endl; t1 = t2; t2 = tn; } } return 0;}

Output

输出量

First run:Enter the number of terms desired in the lucas series: 5Lucas series for 5 terms is:21347Second run:Enter the number of terms desired in the lucas series: 10Lucas series for 10 terms is:213471118294776

翻译自:

32位系统能够识别多达内存

转载地址:http://fpvzd.baihongyu.com/

你可能感兴趣的文章
41025 ISD Assignment 2 Autumn 2019
查看>>
JavaScript跨域调用基于JSON的RESTful API
查看>>
js 右击事件
查看>>
POJ1426:Find The Multiple(算是bfs水题吧,投机取巧过的)
查看>>
今天突然出现了Property IsLocked is not available for Login '[sa]',我太阳,下面有绝招对付它!...
查看>>
django-admin源码解析
查看>>
pc端字体大小自适应几种方法
查看>>
Linux--Linux下安装JDk
查看>>
Github windows客户端简单上手教程
查看>>
前端面试题:高效地随机选取数组中的元素
查看>>
[.NET] 使用 .NET Framework 開發 ActiveX Control
查看>>
Remote IIS Debugging : Debug your ASP.NET Application which is hosted on "Remote IIS Server"
查看>>
iframe 模拟ajax文件上传and formdata ajax 文件上传
查看>>
个人作品需要的报告
查看>>
7 月 2 日
查看>>
那些盒模型在IE6中的BUG们,工程狮的你可曾遇到过?
查看>>
JVM学习笔记四_垃圾收集器与内存分配策略
查看>>
使用Entity Framwork 保存数据时,提示不能在对象中插入重复键,违反了PRIMARY_KEY约束...
查看>>
Mac上制作Centos7系统U盘安装盘
查看>>
VS2013 堆栈溢出调查(0xC00000FD: Stack overflow)
查看>>