File tree Expand file tree Collapse file tree 1 file changed +9
-5
lines changed Expand file tree Collapse file tree 1 file changed +9
-5
lines changed Original file line number Diff line number Diff line change 8
8
* return (4 * 3 * 2 * 1)). For the test cases, the range will be between 1 and 18. * *
9
9
* *
10
10
* 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. *
14
17
* *
15
18
* Steps for solution *
16
19
* 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 *
19
23
* *
20
24
***************************************************************************************/
21
25
You can’t perform that action at this time.
0 commit comments