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. 正则表达式(grep,awk,sed)和通配符

    1. 正则表达式 1. 什么是正则表达式? 正则表达式就是为了处理大量的字符串而定义的一套规则和方法. 通过定义的这些特殊符号的辅助,系统管理员就可以快速过滤,替换或输出需要的字符串. Linux正则 ...

  2. BootStrap的栅格式布局

    1.栅格系统(布局) Bootstrap内置了一套响应式.移动设备优先的流式栅格系统,随着屏幕设备或视口(viewport)尺寸的增加,系统会自动分为最多12列. 我在这里是把Bootstrap中的栅 ...

  3. dlopen failed: empty/missing DT_HASH in "libx.so" (built with --hash-style=gnu?)

    崩溃日志内容: java.lang.UnsatisfiedLinkError: dlopen failed: empty/missing DT_HASH in "libxxxx.so&quo ...

  4. 无向图双连通分量BCC(全网最好理解)

    不是标题党,之前我也写过一篇比较全的,但是对于初学者不友好.传送门? 双连通分量(Biconnected component):     1.边双联通 E-BCC     2.点双连通 V-BCC 双 ...

  5. 一只简单的网络爬虫(基于linux C/C++)————利用正则表达式解析页面

    我们向一个HTTP的服务器发送HTTP的请求后,服务器会返回可能一个HTML页面(当然也可以是其他的资源),我们可以利用返回的HTML页面,在其中寻找其他的Url,例如我们可以这样在浏览器上查看一下H ...

  6. ModuleNotFoundError: No module named 'pip'的解决方案

    python在通过cmd安装pandas时遇到ModuleNotFoundError: No module named 'pip'的报错. 网上查询后通过如下两行cmd命令解决了 python -m ...

  7. P2380狗哥采矿(状态不易设计)

    描述:https://www.luogu.com.cn/problem/P2380 首先分析一下,易知传送带一定是要么向上,要么向右.且一定摆满了整个矩阵. 所以我们设 f [ i ] [ j ]表示 ...

  8. SpringData Redis的简单使用

    SpringDate Redis是在Jedis框架的基础之上对Redis进行了高度封装,通过简单的属性配置就可以通过调用方法完成对Redis数据库的操作,而且SpringData Redis使用了连接 ...

  9. OpenWrt R2020.3.11 去广告 抗污染 加速 PSW 无缝集成 UnPnP NAS

    近期更新:OpenWrt R2020.3.11版本2020.03.16编译. 按大家要求,新发布固件携带了编译时用到的全部软件包 加入了国内域名加速解析脚本 解决了原去广告,DNS优化方案与PSW冲突 ...

  10. 【Spark】Spark-shell案例——单词计数统计

    目录 步骤 一.准备本地文件以作测试 二.通过 --master启动本地模式 三.开发scala单词统计代码 步骤 一.准备本地文件以作测试 在第一台机器执行 mkdir -p /export/ser ...