OFFSET
1,1
COMMENTS
This sequence is similar to A007629 (Keith numbers). It consists of the numbers n>9 with the following property: n is a term of the sequence S whose first k terms are the k digits of n (with the first term equal to the units digit) and with S(n+1)=sum of the k previous terms.
EXAMPLE
42 is in the sequence because the terms of the sequence it creates are 2, 4, 6, 10, 16, 26, 42, ...
MATHEMATICA
iKeithQ[n_Integer] := Module[{b = Reverse[IntegerDigits[n]], s, k = 0}, s = Total[b]; While[s < n, AppendTo[b, s]; k++; s = 2*s - b[[k]]]; s == n]; Select[Range[10, 100000], iKeithQ] (* T. D. Noe, Mar 15 2011 *)
PROG
Here is a (messy) C++ code which finds the terms of the sequence below 100000000
#include <stdio.h>
int main()
{
int k2;
for ( int k = 10 ; k < 100000000 ; k++ )
{
k2 = k;
int array [9];
for ( int i = 0 ; i <= 8; i++ )
{
array[i] = k2 % 10;
k2 /= 10;
}
bool c = true;
int check=8;
for ( int i = 0; i <=8; i++ )
{
if ((array[8-i]==0)&&c)
check--;
else
c=false;
}
bool b = false;
int n = 0;
while ( n <= k && !b )
{
n = 0;
for ( int i = 0; i <= check; i++ )
n += array[i];
if ( n == k )
b = true;
for ( int i = 0 ; i < check ; i++ )
array[i] = array[i+1];
array[check] = n;
}
if ( b )
printf("%d
", k);
}
return 0;
}
CROSSREFS
KEYWORD
base,nonn
AUTHOR
Pierre Karpman (pierre.karpman(AT)laposte.net), Oct 23 2007
STATUS
approved