Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit 697c840

Browse files
committed
Fix syntax (using JavaScript Standard Style)
1 parent 7027515 commit 697c840

File tree

1 file changed

+10
-11
lines changed

1 file changed

+10
-11
lines changed

‎Project-Euler/Problem020.js

Lines changed: 10 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -11,21 +11,20 @@
1111
* Find the sum of the digits in the number 100!
1212
*/
1313

14-
const factorialDigitSum = function (n = 100) {
15-
14+
const factorialDigitSum = (n = 100) => {
1615
// Consider each digit*10^exp separately, right-to-left ([units, tens, ...]).
17-
let digits = [1];
16+
const digits = [1]
1817

19-
for (let x=2; x<=n; x++) {
20-
let carry = 0;
21-
for (let exp=0; exp<digits.length; exp++) {
22-
const prod = digits[exp]*x + carry;
23-
carry = Math.floor(prod/10);
24-
digits[exp] = prod % 10;
18+
for (let x=2; x<=n; x++) {
19+
let carry = 0
20+
for (let exp=0; exp<digits.length; exp++) {
21+
const prod = digits[exp]*x + carry
22+
carry = Math.floor(prod/10)
23+
digits[exp] = prod % 10
2524
}
2625
while (carry > 0) {
27-
digits.push(carry%10);
28-
carry = Math.floor(carry/10);
26+
digits.push(carry%10)
27+
carry = Math.floor(carry/10)
2928
}
3029
}
3130

0 commit comments

Comments
(0)

AltStyle によって変換されたページ (->オリジナル) /