Last active
July 13, 2022 12:04
-
-
Save usmanovrustam/99137c23acad51822d728e6e07fc57ca to your computer and use it in GitHub Desktop.
Given an integer number, value, write a function that returns its multiplicative persistence.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| int multiplicativePersistence(int value) { | |
| int counts = 0; | |
| int temp; | |
| while (value > 9) { | |
| temp = 1; | |
| while (value > 0) { | |
| temp *= value % 10; | |
| value = (value ~/ 10); | |
| } | |
| value = temp; | |
| counts++; | |
| } | |
| return counts; | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment