1. 程式人生 > >用js寫水仙花數

用js寫水仙花數

amp == 位數 等於 parse lse div 就是 ()

...js //輸入一個三位數,水仙花數就是個位的三次方+十為的三次方+百位的三次方之和等於本身 console.log(‘請輸入一個三位數:‘); let a = readline.question(); if (a > 100 && a <= 999) { if (parseInt(a / 100) ** 3 + parseInt(a % 100 / 10) ** 3 + parseInt(a % 10) ** 3 == a) { console.log(parseInt(a)); console.log(‘是水仙花數:‘); } else { console.log(‘不是水仙花數:‘); } }else{ console.log(‘非法數字‘); } ....

用js寫水仙花數