Skip to content

Instantly share code, notes, and snippets.

@usmanovrustam
Last active July 13, 2022 12:04
Show Gist options
  • Select an option

  • Save usmanovrustam/99137c23acad51822d728e6e07fc57ca to your computer and use it in GitHub Desktop.

Select an option

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.
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