题解 | #挑7#
挑7
https://www.nowcoder.com/practice/ba241b85371c409ea01ac0aa1a8d957b
简单题 把条件定好即可 完整代码如下:
const rl = require("readline").createInterface({ input: process.stdin }); var iter = rl[Symbol.asyncIterator](); const readline = async () => (await iter.next()).value; void async function () { // Write your code here while(line = await readline()){ let n = parseInt(line); let arr = Array.from(Array(n+1).keys()); arr.shift(); let res = []; for (let i = 0; i < arr.length; i++) { if (arr[i].toString().match(/7/g) || arr[i]%7 == 0) { res.push(arr[i]) } } console.log(res.length); } }()