1. 程式人生 > 其它 >The absolute uri: http://java.sun.com/jsp/jstl/core cannot be resolved in either web.xml or the jar

The absolute uri: http://java.sun.com/jsp/jstl/core cannot be resolved in either web.xml or the jar

技術標籤:《劍指offer》演算法leetcode面試

劍指 Offer 17. 列印從1到最大的n位數

題目描述:

輸入數字 n,按順序打印出從 1 到最大的 n 位十進位制數。比如輸入 3,則打印出 1、2、3 一直到最大的 3 位數 999。

示例:

輸入: n = 1
輸出: [1,2,3,4,5,6,7,8,9]

思路:

最主要是要找出最大的那個數字,然後迴圈輸出結果

程式碼:

var printNumbers = function(n) {
let res = [];
let max = Math.pow(10,n)-1;
for(let i=1;i<=max;i++
){ res.push(i); } return res; };