题解 | #自守数#
自守数
http://www.nowcoder.com/practice/88ddd31618f04514ae3a689e83f3ab8e
- 我是用正则去判断结尾是否符合的!!
// 按规则去遍历吧 正则!!
let n = parseInt(readline())
let total = 0
while (n >= 0) {
let str = n*n.toString();
let reg = new RegExp(`${n}$`)
if (reg.test(str)) {
total++
}
n--
}
console.log(total)