Skip to content

Commit 1ab645c

Browse files
committed
Update Multiplicative Persistence
1 parent 041c60a commit 1ab645c

File tree

1 file changed

+9
-5
lines changed

1 file changed

+9
-5
lines changed

Multiplicative Persistence

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -8,14 +8,18 @@
88
* return (4 * 3 * 2 * 1)). For the test cases, the range will be between 1 and 18. * *
99
* *
1010
* SOLUTION *
11-
* You can either use an iterative or recursive function to solve this challenge. *
12-
* I am going to use an interative function. I am going to start with a value of 1 *
13-
* for my total and then keep multiplying it by the next number until I reach num. *
11+
* The challenge passes a string but it expects us to do Math on it so it needs to *
12+
* be converted to numbers. I will use the base 10 parameter of the toString() *
13+
* function to convert each entry in the array to a Number. Then I am going to *
14+
* multiply each entry in the array to get a total. I will repeat this until my *
15+
* total is a single digit number. The number of times I multiplied is returned *
16+
* as the answer. *
1417
* *
1518
* Steps for solution *
1619
* 1) Initialize vars sum and loop *
17-
* 2) Loop from 2 to num and multiple tot by num to get new tot. *
18-
* 3) Return tot for answer. *
20+
* 2) Convert str to an array of numbers *
21+
* 3) Loop until the sum of digits in array is a single digit number *
22+
* 4) Return number of loops as answer *
1923
* *
2024
***************************************************************************************/
2125

0 commit comments

Comments
 (0)