回文数
设n是一任意自然数。若将n的各位数字反向排列所得自然数n1与n相等,则称n为一回文数。
//回文数 let readline = require("readline-sync"); console.log("请输入数字:"); let num = parseInt(readline.question("")); let newNum = 0; for(temp=num;temp!=0;temp=parseInt(temp/10)){ newNum = newNum*10+temp%10; } newNum===num?console.log("是回文数"):console.log("不是回文数");
来源:https://www.cnblogs.com/CccK-html/p/11381018.html