OFFSET
1,2
COMMENTS
An integer is a member if, when its digits are added from left to right, the sum is divisible by 3 only when all the digits have been added.
If m is in the sequence then so is m1 = m + 3*10^k and m1 and m have the same number of digits such that the addition gives no carries. For example, 12 is in the sequence so is 12 + 30 = 42 as there is no carry and 12 and 42 have the same number of digits.
LINKS
Cyril Naud, Table of n, a(n) for n = 1..9999
EXAMPLE
117 is a term because the consecutive sums are 1, 2(=1+1), 9(=1+1+7) : only the last sum is divisible by 3.
123 is not a term because 1+2 is divisible by 3.
PROG
(JavaScript)
var i=0, sequence=[];
while(true)
{
var i_str=i.toString();
var digits=[];
for(var j=0; j<is.length; j++)
digits.push(parseInt(i_str.charAt(j)));
var sum=0, ok=true;
for(var k=0; k<digits.length; k++)
{
sum+=digits[k];
if((sum%n==0&&k<digits.length-1)||(sum%n!=0&&k==digits.length-1))
ok=false
}
if(ok)
sequence.push(i);
i++;
}
(PARI) is(n) = if(n / 3 != n \ 3, return(0)); my(d = digits(n), s = 0); for(i = 1, #d - 1, s += d[i]; if(s % 3 == 0, return(0))); 1 \\ David A. Corneth, Jan 14 2019
CROSSREFS
KEYWORD
nonn,base,easy
AUTHOR
Cyril Naud, Jan 14 2019
STATUS
approved