We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent 46d203c commit 7ba5e47Copy full SHA for 7ba5e47
6kyus/js/persistentBugger.js
@@ -0,0 +1,18 @@
1
+// input is a positive integer
2
+// return single digit integer
3
+
4
+// multiplicative persistence is number of times you must multiply the digits in num until you reach a single digit
5
+// if num is single digit already then it should return 0
6
7
+function persistence(num) {
8
+ // pseudocode:
9
+ // create counter
10
+ // create a while loop that only runs when num is less than 10
11
+ // convert num to string
12
+ // string to array
13
+ // reduce to new num
14
+ // return num
15
+}
16
17
+console.log(persistence(39), 3)
18
+console.log(persistence(999), 4)
0 commit comments