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.
Original entry on oeis.org
2, 2, 6, 3, 10, 12, 14, 48, 160, 148, 226, 54, 1277, 2675, 6812, 2525
Offset: 2
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).
Cf.
A258103 (number of pandigital squares in base n).
-
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
-
# 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
A370371
Largest m such that any two consecutive digits of the base-n expansion of m^2 differ by 1 after arranging the digits in decreasing order.
Original entry on oeis.org
1, 1, 15, 2, 195, 867, 3213, 18858, 99066, 528905, 2950717, 294699, 105011842, 659854601, 4285181505, 1578809181, 198009443151, 1404390324525, 10225782424031, 3635290739033, 583655347579584, 4564790605900107, 36485812146621733, 297764406866494254, 2479167155959358950
Offset: 2
Base 4: 15^2 = 225 = 3201_4;
Base 6: 195^2 = 38025 = 452013_6;
Base 7: 867^2 = 751689 = 6250341_7;
Base 8: 3213^2 = 10323369 = 47302651_8;
Base 9: 18858^2 = 355624164 = 823146570_9;
Base 10: 99066^2 = 9814072356;
Base 11: 528905^2 = 279740499025 = A8701245369_11;
Base 12: 2950717^2 = 8706730814089 = B8750A649321_12;
Base 13: 294699^2 = 86847500601 = 8260975314_13.
The actual squares are given by
A370611.
-
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) = forstep(m=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)), 0, -1, if(isconsecutive(m^2,n), return(m)))
-
from math import isqrt
from sympy import multiplicity
from sympy.ntheory import digits
def a(n):
ub = isqrt(sum(i*n**i for i in range(n)))
if n%2 == 1 and multiplicity(2, n-1)%2 == 0:
ub = isqrt(sum(i*n**(i-2) for i in range(2, n)))
return(next(i for i in range(ub, -1, -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, 13)]) # Michael S. Branicky, Feb 23 2024
Showing 1-2 of 2 results.
Comments