Let s ( n ) denotes the sum of the digits of the positive integer n . For example, s ( 5 2 1 ) = 5 + 2 + 1 = 8 .
Define a sequence { a n } where a 1 = 5 2 1 and a k + 1 = a k + s ( a k ) for each k ≥ 1 . Find the smallest value of a m for which a m > 1 0 0 0 .
This section requires Javascript.
You are seeing this because something didn't load right. We suggest you, (a) try
refreshing the page, (b) enabling javascript if it is disabled on your browser and,
finally, (c)
loading the
non-javascript version of this page
. We're sorry about the hassle.
{ 5 2 1 , 5 2 9 , 5 4 5 , 5 5 9 , 5 7 8 , 5 9 8 , 6 2 0 , 6 2 8 , 6 4 4 , 6 5 8 , 6 7 7 , 6 9 7 , 7 1 9 , 7 3 8 , 7 5 2 , 7 6 6 , 7 8 5 , 8 0 5 , 8 1 8 , 8 3 5 , 8 5 1 , 8 6 5 , 8 8 4 , 9 0 4 , 9 1 7 , 9 3 4 , 9 5 0 , 9 6 4 , 9 8 3 , 1 0 0 3 ⋯ } . The first number over 1 0 0 0 is 1 0 0 3 .
Problem Loading...
Note Loading...
Set Loading...
<?php
$arr = array(521); //start with 521 as stated in question
do {
$a = $arr[count($arr)-1]; // get last value in array
$s = array_sum(str_split($a)); // sum of digits
$arr[] = $a+$s; //enter new value into sequence
} while($arr[count($arr)-1]<1000); //stop when we find a number > 1000
//print the answer
echo $arr[count($arr)-1].'<br>'; // 1003
//print the whole sequence
echo '<pre>'.print_r($arr,true).'</pre>'; // (see Joshua's answer for entire sequence)
?>