<?php function getDigit($Nth){ if($Nth < 10) return $Nth; $no_of_digits = 1; $current_contribution = 9; $actual_length = 9; $prev_length = 0; $starting_number = 1; $power_of_10 = 1; while($actual_length < $Nth){ $no_of_digits++; $current_contribution *= 10; $prev_length = $actual_length; $actual_length += ($current_contribution * $no_of_digits); $power_of_10 *= 10; $starting_number *= 10; } $Nth = $Nth - $prev_length; $offset = $Nth % $no_of_digits === 0 ? intval($Nth / $no_of_digits) - 1 : intval($Nth / $no_of_digits); $number = strval($starting_number + $offset); for($i=1;$i<=$no_of_digits;++$i){ if(($Nth - $i) % $no_of_digits === 0){ return $number[$i-1]; } } } for($i=1;$i<=100;++$i){ echo getDigit($i),PHP_EOL; }
You have javascript disabled. You will not be able to edit any code.
Value for `_results` contains invalid data `array`