アルゴリズム45-CountbyX
1681 ワード
Q.
Create a function with two arguments that will return an array of the first (n) multiples of (x).
Assume both the given number and the number of times to count will be positive numbers greater than 0.
Return the results as an array (or list in Python, Haskell or Elixir).
Examples:
countBy(1,10) === [1,2,3,4,5,6,7,8,9,10]
countBy(2,5) === [2,4,6,8,10]
A) function countBy(x, n) {
let z = [];
for (let i = x; i <= x * n; i += x) z.push(i);
return z;
}
Reference
この問題について(アルゴリズム45-CountbyX), 我々は、より多くの情報をここで見つけました
https://velog.io/@tamagoyakii/알고리즘-45-Count-by-X
テキストは自由に共有またはコピーできます。ただし、このドキュメントのURLは参考URLとして残しておいてください。
Collection and Share based on the CC Protocol
function countBy(x, n) {
let z = [];
for (let i = x; i <= x * n; i += x) z.push(i);
return z;
}
Reference
この問題について(アルゴリズム45-CountbyX), 我々は、より多くの情報をここで見つけました https://velog.io/@tamagoyakii/알고리즘-45-Count-by-Xテキストは自由に共有またはコピーできます。ただし、このドキュメントのURLは参考URLとして残しておいてください。
Collection and Share based on the CC Protocol