Floyd's Triangle
Floyd's Triangle
Floyd’s triangle is a right-angled triangular array of natural numbers.
Floyd's triangle是自然数的直角三角形数组
It is defined by filling the rows of the triangle with consecutive numbers, starting with a 1 in the top left corner.
它是通过用连续的数字填充三角形的行来定义的,从左上角的1开始。
The numbers along the left edge of the triangle are the lazy caterer’s sequence and the numbers along the right edge are the triangular numbers.
The nth row sums to n(n^n + 1)/2, the constant of an n × n magic square.
Example: Floyd’s Triangle with a depth of 5.
示例:深度为5的弗洛伊德三角
var tempStr = "", prevNumber=1, i, j, depth = 10;
for (i = 0; i < depth;i++) {
tempStr = "";
j=0;
while (j <= i) {
tempStr = tempStr + " " + prevNumber;
j++;
prevNumber++;
}
console.log(tempStr);
}
Output
1
2 3
4 5 6
7 8 9 10
11 12 13 14 15
16 17 18 19 20 21
22 23 24 25 26 27 28
29 30 31 32 33 34 35 36
37 38 39 40 41 42 43 44 45
46 47 48 49 50 51 52 53 54 55
Floyd's Triangle的更多相关文章
- Must practice programming questions in all languages
To master any programming languages, you need to definitely solve/practice the below-listed problems ...
- floyd算法学习笔记
算法思路 路径矩阵 通过一个图的权值矩阵求出它的每两点间的最短路径矩阵.从图的带权邻接矩阵A=[a(i,j)] n×n开始,递归地进行n次更新,即由矩阵D(0)=A,按一个公式,构造出矩阵D(1):又 ...
- [LeetCode] Triangle 三角形
Given a triangle, find the minimum path sum from top to bottom. Each step you may move to adjacent n ...
- [LeetCode] Pascal's Triangle II 杨辉三角之二
Given an index k, return the kth row of the Pascal's triangle. For example, given k = 3,Return [1,3, ...
- [LeetCode] Pascal's Triangle 杨辉三角
Given numRows, generate the first numRows of Pascal's triangle. For example, given numRows = 5,Retur ...
- 最短路(Floyd)
关于最短的先记下了 Floyd算法: 1.比较精简准确的关于Floyd思想的表达:从任意节点A到任意节点B的最短路径不外乎2种可能,1是直接从A到B,2是从A经过若干个节点X到B.所以,我们假设maz ...
- 【leetcode】Pascal's Triangle II
题目简述: Given an index k, return the kth row of the Pascal's triangle. For example, given k = 3, Retur ...
- 【leetcode】Pascal's Triangle
题目简述: Given numRows, generate the first numRows of Pascal's triangle. For example, given numRows = 5 ...
- POJ 1163 The Triangle(简单动态规划)
http://poj.org/problem?id=1163 The Triangle Time Limit: 1000MS Memory Limit: 10000K Total Submissi ...
随机推荐
- 【Linux常见命令】ls命令
ls - list directory contents ls命令用于显示指定工作目录下之内容(列出目前工作目录所含之文件及子目录). 语法: ls [OPTION]... [FILE]... l ...
- 13.Python中的命名空间是什么
Python中的命名空间是什么? In Python,every name introduced has a place where it lives and can be hooked for. T ...
- WMware中Ubuntu系统安装VMware tools
在VMware的虚拟机中安装完ubuntu之后,继续安装VMware tools. 一般情况下,这时都有光驱的图标,点开就能找到"VMwareTools-10.0.10-4301679.ta ...
- “Too many texture interpolators would be used for ForwardBase pass”
CGPROGRAM 下加一个 #pragma target 4.0 转载于:https://www.cnblogs.com/alps/p/7101092.html
- "net.sf.hibernate.PropertyValueException"
2019独角兽企业重金招聘Python工程师标准>>> 如果你遇到了下面的错误信息,例如: ERROR [Importing data task] [confluence.impor ...
- 数据库SQL语言从入门到精通--Part 6--单表查询(快来PICK)
数据库从入门到精通合集(超详细,学习数据库必看) 查询操作是SQL语言中很重要的操作,我们今天就来详细的学习一下. 一.数据查询的语句格式 SELECT [ALL|DISTINCT] <目标列表 ...
- redis系列之2----详细讲解redis数据结构(内存模型)以及常用命令
Redis数据类型 与Memcached仅支持简单的key-value结构的数据记录不同,Redis支持的数据类型要丰富得多,常用的数据类型主要有五种:String.List.Hash.Set和Sor ...
- memcached线程模型
直接上图: memcached使用多线程模型,一个master线程,多个worker线程,master和worker通过管道实现通信. 每个worker线程有一个队列,队列元素为CQ_ITEM. ty ...
- P1364 医院设置(树型结构)
传送门闷闷闷闷闷闷 ~~放一个可爱的输入框.~~ 考虑在O(n)的时间内求数以每个节点为医院的距离和. \(设想一下,如果我们已知以1为根节点的距离和f[1],如何求出子节点呢?\) 当医院从1转换到 ...
- php使用curl post josn数据
今天在工作中使用到要使用("Content-Type", "application/json;charset=UTF-8")格式传送和接受数据,再次做个记录 p ...