[go: up one dir, main page]

login
A370370
Number of squares such that any two consecutive digits of their base-n expansions differ by 1 after arranging the digits in decreasing order.
4
2, 2, 6, 3, 10, 12, 14, 48, 160, 148, 226, 54, 1277, 2675, 6812, 2525
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.
a(10) = 160 because there are 160 terms in A370362 (or A370610).
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
Cf. A258103 (number of pandigital squares in base n).
Sequence in context: A081745 A240578 A273105 * A307966 A129889 A263673
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