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的更多相关文章

  1. Must practice programming questions in all languages

    To master any programming languages, you need to definitely solve/practice the below-listed problems ...

  2. floyd算法学习笔记

    算法思路 路径矩阵 通过一个图的权值矩阵求出它的每两点间的最短路径矩阵.从图的带权邻接矩阵A=[a(i,j)] n×n开始,递归地进行n次更新,即由矩阵D(0)=A,按一个公式,构造出矩阵D(1):又 ...

  3. [LeetCode] Triangle 三角形

    Given a triangle, find the minimum path sum from top to bottom. Each step you may move to adjacent n ...

  4. [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, ...

  5. [LeetCode] Pascal's Triangle 杨辉三角

    Given numRows, generate the first numRows of Pascal's triangle. For example, given numRows = 5,Retur ...

  6. 最短路(Floyd)

    关于最短的先记下了 Floyd算法: 1.比较精简准确的关于Floyd思想的表达:从任意节点A到任意节点B的最短路径不外乎2种可能,1是直接从A到B,2是从A经过若干个节点X到B.所以,我们假设maz ...

  7. 【leetcode】Pascal's Triangle II

    题目简述: Given an index k, return the kth row of the Pascal's triangle. For example, given k = 3, Retur ...

  8. 【leetcode】Pascal's Triangle

    题目简述: Given numRows, generate the first numRows of Pascal's triangle. For example, given numRows = 5 ...

  9. POJ 1163 The Triangle(简单动态规划)

    http://poj.org/problem?id=1163 The Triangle Time Limit: 1000MS   Memory Limit: 10000K Total Submissi ...

随机推荐

  1. 《数据分析实战:基于EXCEL和SPSS系列工具的实践》一1.4 数据分析的流程

    本节书摘来华章计算机<数据分析实战:基于EXCEL和SPSS系列工具的实践>一书中的第1章 ,第1.4节,纪贺元 著 更多章节内容可以访问云栖社区"华章计算机"公众号查 ...

  2. 流畅的python读书笔记-第十章-继承优缺点

    继承的优缺点 推出继承的初衷是让新手顺利使用只有专家才能设计出来的框架.--Alan Kay 子类化内置类型很麻烦 (如 list 或 dict)) ,别搞这种 直接子类化内置类型(如 dict.li ...

  3. 短视频sdk:选择一个靠谱的短视频SDK 你需要了解这些

    2017 年,短视频成为了内容创业的新风口,各种短视频 App 如雨后春笋般先后上线.随着互联网内容消费升级,视频越来越像文字.图片一样,成为每一个 App 不可或缺的一部分. 为了能够更好地聚焦于业 ...

  4. Bind+DLZ+MySQL智能DNS的正向解析和反向解析实现方法

    使用文本配置文件的配置方式结合bind的最新的acl和view特性来实现智能DNS想必很多人已经很熟悉了,使用MySQL数据库来存放zone文件的方式可能也不少.对于两者都熟悉的,实现 Bind+DL ...

  5. python selenium(定位方法)

    一.定位方法 注意:元素属性必须唯一存在 #id定位 find_element_by_id() #name定位 find_element_by_name() #class_name定位 find_el ...

  6. IDEA 打可执行jar包(maven项目)

    1. Ctrl+Shift+Alt+S  打开 Project Structure  2.选择要执行的文件,  依次选择 项目, 方法所在文件(必须有main方法), 保存 3.如果之前路径下曾经打过 ...

  7. 【网络基础】ARP地址解析协议

    ARP(Address Rssolution Protocol) 地址解析协议 用于将IP地址解析为MAC地址. MAC地址是设备的物理地址,是被分配给每一个网络接口卡的全球唯一序号. 全球唯一:理论 ...

  8. 时间日期相关类:Date类,DateFormat类&SimpleDateFormat类,Calendar类

    日期相关类 1.Date类:日期时间类 A.构造方法 Date(): 根据当前系统时间创建日期对象 ​ Date(Long time):根据传入的毫秒值时间创建日期对象 B.成员方法 Long get ...

  9. apache反向代理和负载均衡

    正向代理:正如我们用的游戏加速代理,大多的个人PC把请求发给正向代理服务器,代理服务器通常配置高端的带宽,替我们请求相应的服务 负载均衡中的反向代理:通常意义上,是一个请求转发的代理.类似一个收发室的 ...

  10. RabbitMQ的使用(二)- RabbitMQ服务在单机中做集群

    RabbitMQ的使用(二)- RabbitMQ服务在单机中做集群 作者:markjiang7m2 原文地址:https://www.cnblogs.com/markjiang7m2/p/128371 ...