当前位置:网站首页>js求所有水仙花数
js求所有水仙花数
2022-06-27 07:20:00 【I am the sun?】
代码:
<!DOCTYPE html>
<html lang="zh">
<head>
<meta charset="UTF-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<meta http-equiv="X-UA-Compatible" content="ie=edge" />
<title>js求所有水仙花数</title>
<script type="text/javascript">
for(var i = 100;i <= 999;i++){
// 个位
var a = i % 10;
// 十位,因为 / 会计算到小数点,因此要取整
var b = parseInt(i% 100 / 10);
// 百位 同上,也是因为 / ,所以要取整
var c =parseInt(i / 100);
if((a*a*a + b*b*b + c*c*c) ==i)
console.log(a + "*" + a + "*" + a + "+"+ b + "*" + b + "*" + b +"+"+ c + "*" + c + "*" + c +"=" + i);
}
</script>
</head>
<body>
</body>
</html>
运行结果:
调出控制台,只要这样:
边栏推荐
- Bean copy details
- RNA SEQ data analysis in R - investigate differentially expressed genes in the data!
- 如何优雅的写 Controller 层代码?
- Centos7.9 install MySQL 5.7 and set startup
- R 中的 RNA-Seq 数据分析 - 调查数据中的差异表达基因!
- oracle的similarity方法实现原理
- 请问如何在网页通过excel文件的形式向后段数据库添加数据
- 语音信号特征提取流程:输入语音信号-分帧、预加重、加窗、FFT->STFT谱(包括幅度、相位)-对复数取平方值->幅度谱-Mel滤波->梅尔谱-取对数->对数梅尔谱-DCT->FBank->MFCC
- Speech signal feature extraction process: input speech signal - framing, pre emphasis, windowing, fft- > STFT spectrum (including amplitude and phase) - square the complex number - > amplitude spectru
- The interviewer of a large front-line factory asked: do you really understand e-commerce order development?
猜你喜欢
![log4j:WARN No such property [zipPermission] in org.apache.log4j.RollingFileAppender.](/img/2c/425993cef31dd4c786f9cc5ff081ef.png)
log4j:WARN No such property [zipPermission] in org.apache.log4j.RollingFileAppender.

进程终止(你真的学会递归了吗?考验你的递归基础)

正斜杠反斜杠的由来

From 5 seconds to 1 second, the system flies

用XGBoost迭代读取数据集

Process termination (have you really learned recursion? Test your recursion Foundation)

Xiaomi Interviewer: let's talk about the proficient Registration Center for three days and three nights

Rust Async: smol源码分析-Executor篇

The interviewer of a large front-line factory asked: do you really understand e-commerce order development?

cookie加密7 fidder分析阶段
随机推荐
apifox学习
postgreSQL在windows系统遇到权限否认(permission denied)
IDEA连接数据库报错
How to download opencv? How to configure opencv after downloading?
oracle的similarity方法实现原理
R language consumption behavior statistics based on association rules and cluster analysis
C# 请问怎么在更新数据库时候调用line与rows
再见了,敏捷Scrum
Win10 remote connection to ECS
Bean copy details
【OpenAirInterface5g】RRC NR解析之RrcSetupComplete
YOLOv6又快又准的目标检测框架 已开源
剑指 Offer 07. 重建二叉树
Hutool symmetric encryption
boundvalueops和opsforvalue区别
Interviewer: do you have any plan to request a lot of data that does not exist in redis to destroy the database?
JDBC事务提交事例
js中如何查看程序运行时间(计时器)
Interviewer: please introduce cache penetration, cache null value, cache avalanche and cache breakdown, which are easy to understand
The first part of the construction of the defense system of attack and defense exercise is the introduction and the four stages of Defense