OFFSET
1,1
COMMENTS
Numbers m such that the base-4 representation of (3*m-1) starts with 11 or 12 or 13 or ends with 0.
First differences give a run of 4^i 1's followed by a run of 4^i 4's, for i = 0, 1, 2, ...
LINKS
FORMULA
For n in the range (2*4^i + 1)/3 < n <= (5*4^i + 1)/3, for i >= 0:
a(n) = n + 4^i.
a(n) = 1 + a(n-1).
Otherwise, for n in the range (5*4^i + 1)/3 < n <= (8*4^i + 1)/3, for i >= 0:
a(n) = 4*(n - 4^i) - 1.
a(n) = 4 + a(n-1).
EXAMPLE
a(6) = 10 because (2*4^1 + 1)/3 < 6 <= (5*4^1 + 1)/3, hence a(6) = 6 + 4^1 = 10;
a(9) = 19 because (5*4^1 + 1)/3 < 9 <= (8*4^1 + 1)/3, hence a(9) = 4*(9 - 4^1) - 1 = 19.
MAPLE
isA353651 := proc(n)
if modp(n, 4) = 3 then
true;
else
b4 := convert(3*n-1, base, 4) ;
if op(-1, b4) = 1 and op(-2, b4) <> 0 then
true ;
else
false;
end if;
end if;
end proc:
for n from 2 to 122 do
if isA353651(n) then
printf("%d, ", n) ;
end if;
end do: # R. J. Mathar, Jul 05 2022
PROG
(PARI) a(n) = my(n3=3*n, s=logint(n3>>1, 4)<<1); if(n3>>s < 5, n + 1<<s, 4*(n - 1<<s) - 1); \\ Kevin Ryde, Apr 15 2022
(C++)
/* program used to generate the b-file */
#include<iostream>
using namespace std;
int main(){
int cnt1=1, flag=0, cnt2=1, a=2;
for(int n=1; n<=10000; n++) {
cout<<n<<" "<<a<<endl;
if(cnt2==cnt1) {
flag=1-flag, cnt1=1;
if(flag) a+=1;
else {
a+=4;
cnt2*=4;
}
}
else {
cnt1++;
a+=(flag?4:1);
}
}
return 0;
}
CROSSREFS
KEYWORD
nonn,easy
AUTHOR
Yifan Xie, May 02 2022
STATUS
approved