OFFSET
2,1
EXAMPLE
a(4) = 6 because there are 6 such squares in base 4: 0^2 = 0 = 0_4, 1^2 = 1 = 1_4, 2^2 = 4 = 10_4, 3^2 = 9 = 21_4, 6^2 = 36 = 210_4 and 15^2 = 225 = 3201_4.
a(6) = 10 because there are 10 such squares in base 6: 0^2 = 0 = 0_6, 1^2 = 1 = 1_6, 2^2 = 4 = 2_6, 9^2 = 81 = 213_6, 11^2 = 121 = 321_6, 21^2 = 441 = 2013_6, 50^2 = 2500 = 15324_6, 75^2 = 5625 = 42013_6, 85^2 = 7225 = 53241_6 and 195^2 = 38025 = 452013_6.
PROG
(PARI) isconsecutive(m, n)=my(v=vecsort(digits(m, n))); for(i=2, #v, if(v[i]!=1+v[i-1], return(0))); 1 \\ isconsecutive(k, n) == 1 if and only if any two consecutive digits of the base-n expansion of m differ by 1 after arranging the digits in decreasing order
a(n) = my(lim=sqrtint(if(n%2==1 && valuation(n-1, 2)%2==0, n^(n-1) - (n^(n-1)-1)/(n-1)^2, n^n - (n^n-n)/(n-1)^2)), count=0); for(m=0, lim, if(isconsecutive(m^2, n), count++)); count \\ See A258103 for the searching limit of m
(Python) # replace n**n with ub in A370371 for faster version
from math import isqrt
from sympy.ntheory import digits
def a(n): return(sum(1 for i in range(isqrt(n**n)+1) if len(d:=sorted(digits(i*i, n)[1:])) == d[-1]-d[0]+1 == len(set(d))))
print([a(n) for n in range(2, 12)]) # Michael S. Branicky, Feb 23 2024
CROSSREFS
KEYWORD
nonn,base,hard,more
AUTHOR
Jianing Song, Feb 16 2024
EXTENSIONS
a(15)-a(17) from Michael S. Branicky, Feb 23 2024
STATUS
approved