Skip to content

Instantly share code, notes, and snippets.

@lbvf50mobile
Last active October 23, 2020 17:20
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save lbvf50mobile/39324f096b2c0a5b23559aadf236f010 to your computer and use it in GitHub Desktop.
Save lbvf50mobile/39324f096b2c0a5b23559aadf236f010 to your computer and use it in GitHub Desktop.
Just PHP FUN 136.
<?php
# https://www.codewars.com/kata/55bf01e5a717a0d57e0000ec Persistent Bugger.
function persistence(int $num): int {
for($i = 0; $num >= 10; $i += 1, $num = the_sum($num));
return $i;
}
function the_sum($n){
return array_reduce(str_split(strval($n)),function($acc,$x){return $acc*$x;},1);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment