Displaying 1-6 of 6 results found.
page
1
Number of squares such that any two consecutive digits of their base-n expansions differ by 1 after arranging the digits in decreasing order.
+10
4
2, 2, 6, 3, 10, 12, 14, 48, 160, 148, 226, 54, 1277, 2675, 6812, 2525
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))))
CROSSREFS
Cf. A258103 (number of pandigital squares in base n).
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.
+10
4
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
COMMENTS
By definition, a(n) <= sqrt(Sum_{i=0..n-1} i*n^i) = sqrt( A062813(n)). If n is odd and n-1 has an even number of 2s as prime factors, then there are no pandigital squares in base n, so a(n) <= sqrt(Sum_{i=1..n-1} i*n^(i-1)) = sqrt( A051846(n-1)); see A258103.
If n is odd and n-1 has an even 2-adic valuation, then a(n) <= sqrt(Sum_{i=2..n-1} i*n^(i-2)); see A258103. - Chai Wah Wu, Feb 25 2024
EXAMPLE
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.
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) = 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)))
(Python)
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))))
CROSSREFS
The actual squares are given by A370611.
All pandigital squares which contain each digit exactly once in some base b >= 2. The numbers are written in base 10.
+10
2
225, 38025, 314721, 622521, 751689, 3111696, 6002500, 7568001, 10323369, 61058596, 73513476, 74545956, 94517284, 105144516, 112572100, 112656996, 132756484, 136936804, 181980100, 202948516, 210308004, 211353444, 219573124, 222069604, 230614596, 238208356, 251983876
COMMENTS
The sequence consists of all square numbers which when represented in some base b contain all the b digits in that base exactly once.
A225218 has all the squares in base 10 that are pandigital. This sequence is the union of all such sequences in any integer base b >= 2.
EXAMPLE
15^2 in base 4 (225 is 3201 in base 4) contains the digits 0-3.
195^2 in base 6 (38025 is 452013 in base 6) contains the digits 0-5.
The next three terms contain all the digits in base 7.
The following four entries are pandigital in base 8, the next 26 in base 9, and so on.
PROG
(JAI)
#import "Basic";
dstr := "0123456789abcdef";
main :: () {
digits : [16] int;
for j:2..3_000_000 {
for b:3..16 {
for d : 0..15
digits[d] = 0;
k := j*j;
s := tprint( "%", formatInt( k, b ) );
if s.count > b
continue;
for d : 0..s.count-1 {
for c : 0..dstr.count-1 {
if s[d] == dstr[c] {
digits[c] += 1;
continue d;
}
}
}
for d : 0..b-1 {
if digits[d] != 1
continue b;
}
print( "%, ", k );
}
}
}
(PARI) \\ here ispandig(n) returns base if n is pandigital, otherwise 0.
ispandig(n)={for(b=2, oo, my(r=logint(n, b)+1); if(r<b, break); if(r==b && #Set(digits(n, b))==b, return(b))); 0}
for(n=1, 10^5, if(ispandig(n^2), print1(n^2, ", "))) \\ Andrew Howroyd, Dec 20 2020
Smallest square which when written in base b contains each digit exactly once, or -1 if no such square exists.
+10
2
-1, -1, 225, -1, 38025, 314721, 3111696, 61058596, 1026753849, 31529329225, 892067027049, -1, 803752551280900, 29501156485626049, 1163446635475467225, -1, 2200667320658951859841, 104753558229986901966129, 5272187100814113874556176, -1, 15588378150732414428650569369
COMMENTS
Note that "pandigital" just means every digit appears at least once. The condition here is stronger. Maybe this should be called "Smallest strictly pandigital square in base b"?
Does this sequence contain infinitely many positive terms? Equally, is A339693 infinite?
It is shown in A258103 that a(n) = -1 for n = 2,3,5,13,17,21 and infinitely many other values.
EXAMPLE
base a(base) digits
4 225 [3, 2, 0, 1]
6 38025 [4, 5, 2, 0, 1, 3]
7 314721 [2, 4, 5, 0, 3, 6, 1]
8 3111696 [1, 3, 6, 7, 5, 4, 2, 0]
9 61058596 [1, 3, 6, 8, 0, 2, 5, 7, 4]
10 1026753849 [1, 0, 2, 6, 7, 5, 3, 8, 4, 9]
11 31529329225 [1, 2, 4, 0, 10, 5, 3, 6, 7, 8, 9]
12 892067027049 [1, 2, 4, 10, 7, 11, 5, 3, 8, 6, 0, 9]
14 803752551280900 [1, 0, 2, 6, 9, 11, 8, 12, 5, 7, 13, 3, 10, 4]
PROG
(Python)
from sympy import integer_nthroot
def digits(n, b):
out = []
while n >= b: n, r = divmod(n, b); out.append(r)
return [n] + out[::-1]
def a(n):
b, b2b = n, n**n
r, a = integer_nthroot(b**(b-1), 2); s = r**2
while s < b**(b-1): s += 2*r + 1; r += 1
while s < b2b:
if len(set(digits(s, b))) == n: return s
s += 2*r + 1; r += 1
return -1
Largest square such that any two consecutive digits of its base-n expansion differ by 1 after arranging the digits in decreasing order.
+10
2
1, 1, 225, 4, 38025, 751689, 10323369, 355624164, 9814072356, 279740499025, 8706730814089, 86847500601, 11027486960232964, 435408094460869201, 18362780530794065025, 2492638430009890761, 39207739576969100808801, 1972312183619434816475625, 104566626183621314286288961, 13215338757299095309775089
COMMENTS
By definition, a(n) <= Sum_{i=0..n-1} i*n^i = A062813(n). If n is odd and n-1 has an even number of 2s as prime factors, then there are no pandigital squares in base n, so a(n) <= Sum_{i=1..n-1} i*n^(i-1) = A051846(n-1); see A258103.
If n is odd and n-1 has an even 2-adic valuation, then a(n) <= Sum_{i=2..n-1} i*n^(i-2); see A258103. - Chai Wah Wu, Feb 25 2024
EXAMPLE
See the Example section of A370371.
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) = 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^2)))
CROSSREFS
The square roots are given by A370371.
Number of penholodigital squares (containing each nonzero digit exactly once) in base n.
+10
1
1, 0, 0, 0, 2, 1, 1, 10, 30, 20, 23, 0, 160, 419, 740, 0, 5116
COMMENTS
Theorem: Let m^2 be a pandigital square (containing each digit exactly once) or a penholodigital square (containing each nonzero digit exactly once) in base n. If n-1 is an odd squarefree number ( A056911), then m is divisible by n-1. If n-1 is an even squarefree number ( A039956), then m-(n-1)/2 is divisible by n-1.
Proof: Since n^k == 1 (mod n-1), and the sum of digits of m^2 is n*(n-1)/2, this implies that m^2 == n*(n-1)/2 (mod n-1). If n-1 is odd and squarefree, then n is even and m^2 == 0 (mod n-1). Since n-1 = Product_i p_i for distinct odd primes p_i, and m^2 == 0 (mod p_i) if and only if m == 0 (mod p_i), this implies that m == 0 (mod n-1) by the Chinese Remainder Theorem.
Similarly, if n-1 is even and squarefree, then m^2 == n(n-1)/2 == (n-1)/2 (mod n-1) and (n-1)/2 = Product_i p_i for distinct odd primes p_i, i.e., m^2 == 0 (mod p_i) and m^2 == 1 (mod 2). This implies that m == 0 (mod p_i) and m == 1 (mod 2). Again by the Chinese Remainder Theorem, m == (n-1)/2 (mod n-1).
(End)
FORMULA
If n is odd and n-1 has an even 2-adic valuation, then a(n) = 0 (see A258103).
EXAMPLE
For n=2 there is one penholodigital square, 1_2 = 1 = 1^2.
For n=6 there are two penholodigital squares, 15324_6 = 2500 = 50^2 and 53241_6 = 7225 = 85^2.
For n=7 there is one penholodigital square, 623514_7 = 106929 = 195^2.
For n=8 there is one penholodigital square, 6532471_8 = 1750329 = 1323^2.
For n=10 there are 30 penholodigital squares listed in A036744.
PROG
(Python)
from gmpy2 import mpz, digits, isqrt
def A370950(n): # requires 2 <= n <= 62
if n&1 and (~(m:=n-1>>1) & m-1).bit_length()&1:
return 0
t = ''.join(digits(d, n) for d in range(1, n))
k = mpz(''.join(digits(d, n) for d in range(n-1, 0, -1)), n)
k2 = mpz(t, n)
c = 0
for i in range(isqrt(k2), isqrt(k)+1):
if i%n:
j = i**2
s = ''.join(sorted(digits(j, n)))
if s == t:
c += 1
return c
Search completed in 0.016 seconds
|