当前位置:网站首页>获取水仙花数
获取水仙花数
2022-07-29 05:19:00 【学习记录而已】
获取水仙花数
<script type="text/javascript">
/**
* 水仙花数是指一个3位数,他的每个位上的数字的3次幂之和等于他本身
* (例如:1^3 + 5^3 + 3^3 = 153)请打印所有的水仙花数
*/
//打印所有的三位数
for(var i = 100; i < 1000; i++){
//获取i百位 十位 个位 的数字
//获取百位的数字
var bai = parseInt(i / 100);
//获取十位的数字
var shi = parseInt((i-bai*100)/10);
//获取个位上的数字
var ge = parseInt(i%10);
//判断i是否是水仙花数
if(bai*bai*bai + shi*shi*shi + ge*ge*ge == i){
console.log(i);
}
}
</script>
边栏推荐
猜你喜欢

DAY14:Upload-labs 通关教程

Summary of knowledge points related to forms and forms

Clickhouse learning (V) cluster operation

HCIA-R&S自用笔记(26)PPP
![[C language series] - realize the exchange of two numbers without creating the third variable](/img/7c/468000bcbf740c9dd3535f2734728a.png)
[C language series] - realize the exchange of two numbers without creating the third variable

第五空间智能安全⼤赛真题----------PNG图⽚转换器

table中同一列中合并相同项
![[C language series] - three methods to simulate the implementation of strlen library functions](/img/b2/00cd2b79adc23813088656ec3bc17e.png)
[C language series] - three methods to simulate the implementation of strlen library functions

Detailed installation and use tutorial of MySQL (nanny installation with pictures and texts)

Day 3
随机推荐
表格与表单相关知识点总结
ClickHouse学习(一)ClickHouse?
·Let's introduce ourselves to the way of programming·
[JS question solution] questions 1-10 in JS of niuke.com
Qt布局管理--部件拉伸(Stretch)原理及大小策略(sizePolicy)
ClickHouse学习(六)语法优化
Day 2
Cmu15-213 shell lab experiment record
Qtcreator+cmake compiler settings
Clickhouse learning (VI) grammar optimization
On Paradigm
字符类型转换
What is sqlmap and how to use it
Qframe class learning notes
Record the SQL injection vulnerability of XX company
365 day challenge leetcode 1000 questions - day 035 one question per day + two point search 13
Summary of the first week
[C language series] - storage of deep anatomical data in memory (II) - floating point type
Wechat applet - screen height
Selenium实战案例之爬取js加密数据