1 Star 0 Fork 0

张志光/Leetcode-js

Create your Gitee Account
Explore and code with more than 13.5 million developers,Free private repositories !:)
Sign up
文件
Clone or Download
258.各位相加.html 634 Bytes
Copy Edit Raw Blame History
zhangzhiguang123 authored 2019-09-16 19:34 +08:00 . 力扣
<!DOCTYPE html>
<html lang="en">
<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>Document</title>
</head>
<body>
<script>
var addDigits = function(num) {
function add(num){
let n = 0;
let str = num.toString();
for(var k of str){
n += parseInt(k);
}
return n;
}
while(true){
num = add(num);
if(num<10&&num>0) return num;
}
}
alert(addDigits(52));
</script>
</body>
</html>
Loading...
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
1
https://gitee.com/guangzz/Leetcode-js.git
git@gitee.com:guangzz/Leetcode-js.git
guangzz
Leetcode-js
Leetcode-js
master

Search