login
A257867
Nonnegative integers n such that in balanced ternary representation the number of occurrences of each trit doubles when n is squared.
4
314, 942, 2824, 2826, 2854, 3074, 3130, 3212, 8066, 8090, 8096, 8170, 8224, 8324, 8426, 8450, 8472, 8478, 8480, 8512, 8534, 8562, 8578, 8588, 8656, 9222, 9224, 9390, 9404, 9636, 9638, 24198, 24206, 24270, 24288, 24510, 24670, 24672, 24674, 24676, 24802, 24972
OFFSET
1,1
LINKS
EXAMPLE
942 is in the sequence because 942 = 110L0L0_bal3 and 942^2 = 887364 = 1LL0001L1L0100_bal3, where L represents (-1).
MAPLE
p:= proc(n) local d, m, r; m:=n; r:=0;
while m>0 do
d:= irem(m, 3, 'm');
if d=2 then m:=m+1 fi;
r:=r+x^d
od; r
end:
a:= proc(n) option remember; local k;
for k from 1+`if`(n=1, 0, a(n-1))
while p(k)*2<>p(k^2) do od; k
end:
seq(a(n), n=1..50);
PROG
(Python)
def a(n):
s=[]
x=0
while n>0:
x=n%3
n//=3
if x==2:
x=-1
n+=1
s.append(x)
return s
print([n for n in range(1, 25001) if a(n**2).count(-1)==2*a(n).count(-1) and a(n**2).count(1)==2*a(n).count(1) and a(n**2).count(0)==2*a(n).count(0)]) # Indranil Ghosh, Jun 07 2017
KEYWORD
nonn,base
AUTHOR
Alois P. Heinz, May 11 2015
STATUS
approved