Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public static int Persistence(long n)
- {
- // your code
- string s_n = n.ToString();
- int counter = 0;
- while(s_n.Length != 1)
- {
- s_n = Mult(s_n);
- counter++;
- }
- return counter;
- }
- public static string Mult(string number)
- {
- string s_mult = string.Empty;
- int mult = 1;
- foreach(char n in number)
- {
- mult *= int.Parse(n.ToString());
- }
- s_mult = mult.ToString();
- return s_mult;
- }
Advertisement
Add Comment
Please, Sign In to add comment