<?php function find($n){ $count = 0; $j = 0; for($i = 5; $i <= $n; $i = $i + 5){ $j = $i; while($j % 5 == 0){ $count ++; $j /= 5; } } return $count ; } $a = find(5); var_dump($a);