Showing posts with label permutations. Show all posts
Showing posts with label permutations. Show all posts

Wednesday, 6 May 2026

Pandigital Products

Yesterday I turned 28156 days old and this number has an interesting property:$$28156 = 4 \times 7039$$The factorisation shown is not the prime factorisation but, looking at both sides of the equation, it can be seen that each of the digits from 0 to 9 occurs exactly once. This makes the number a member of OEIS A370970:


A370970
: numbers \(k\) which have a factorization \(k = f_1 \times f_2 \times \ldots \times f_n \) where the digits of \({k, f_1, f_2, \ldots, f_n}\) together give \(0,1, \ldots ,9\) exactly once.

Here is the complete list of terms:

8596 = 2 x 14 x 307

8790 = 2 x 3 x 1465

9360 = 2 x 4 x 15 x 78

9380 = 2 x 5 x 14 x 67

9870 = 2 x 3 x 1645

10752 = 3 x 4 x 896

12780 = 4 x 5 x 639

14760 = 5 x 9 x 328

14820 = 5 x 39 x 76

15628 = 4 x 3907

15678 = 39 x 402

16038 = 27 x 594 = 54 x 297

16704 = 9 x 32 x 58

17082 = 3 x 5694

17820 = 36 x 495 = 45 x 396

17920 = 8 x 35 x 64

18720 = 4 x 5 x 936

19084 = 52 x 367

19240 = 8 x 37 x 65

20457 = 3 x 6819

20574 = 6 x 9 x 381

20754 = 3 x 6918

21658 = 7 x 3094

24056 = 8 x 31 x 97

24507 = 3 x 8169

25803 = 9 x 47 x 61

26180 = 4 x 7 x 935

26910 = 78 x 345

27504 = 3 x 9168

28156 = 4 x 7039

28651 = 7 x 4093

30296 = 7 x 8 x 541

30576 = 8 x 42 x 91

30752 = 4 x 8 x 961

31920 = 5 x 76 x 84

32760 = 8 x 45 x 91

32890 = 46 x 715

34902 = 6 x 5817

36508 = 4 x 9127

47320 = 8 x 65 x 91

58401 = 63 x 927

65128 = 7 x 9304 

65821 = 7 x 9403

These numbers are few and far between as can be seen and 28156 in particular recurs with permuted digits as 15628, 21658, 28651, 65128 and 65821.

Wednesday, 22 April 2026

A + B = C Numbers Revisited

I posted about A + B = C numbers in an eponymous post on the 25th May 2025. However, I only listed the C numbers and did not include the A and B numbers. This is what OEIS A203024 does as well:


OEIS A203024
: n
umbers \(a = b + c\) where \(a\), \(b\), and \(c\) contain the same decimal digits.

For that reason, a number like \( \textbf{28143}\) (my diurnal age today) is missed because it not a sum but part of a sum:$$14238 + \textbf{28143} = 42381$$Since I normally only look at numbers up to 40000, I miss 28143. However, I now addressed that deficiency and incorporated a search into my daily number analysis that will identify A, B and C numbers in the range up to 40000. Here is a list of such numbers above 28000 and below 40000 that I'll call A + B = C numbers (permalink):

28035, 28107, 28134, 28143, 28314, 28341, 28431, 28503, 28530, 28539, 28593, 28746, 28935, 28953, 29016, 29106, 29160, 29214, 29286, 29358, 29367, 29376, 29385, 29457, 29475, 29502, 29520, 29538, 29547, 29574, 29601, 29610, 29637, 29664, 29691, 29736, 29745, 29754, 29763, 29853, 29961, 30168, 30186, 30267, 30276, 30285, 30465, 30627, 30654, 30762, 30825, 31077, 31257, 31275, 31428, 31482, 31509, 31590, 31698, 31752, 31824, 31905, 31950, 31968, 32076, 32148, 32175, 32184, 32481, 32607, 32670, 32697, 32706, 32760, 32769, 32796, 32814, 32850, 32895, 32967, 32976, 32985, 34065, 34128, 34182, 34218, 34281, 34497, 34569, 34578, 34587, 34650, 34659, 34695, 34749, 34758, 34785, 34812, 34821, 34857, 34875, 34947, 34965, 35001, 35010, 35082, 35100, 35109, 35127, 35190, 35289, 35298, 35703, 35712, 35730, 35784, 35874, 35901, 35910, 35928, 36027, 36072, 36198, 36207, 36270, 36279, 36297, 36702, 36720, 36792, 36819, 36918, 36927, 36972, 37026, 37062, 37125, 37206, 37260, 37296, 37305, 37350, 37449, 37494, 37503, 37512, 37521, 37530, 37584, 37602, 37620, 37629, 37692, 37854, 37926, 37962, 38124, 38142, 38214, 38241, 38412, 38421, 38529, 38574, 38619, 38754, 38925, 38952, 39105, 39150, 39267, 39276, 39285, 39447, 39501, 39510, 39627, 39672, 39726, 39744, 39762, 39852

The next such number for me is \( \textbf{28314}\) and it occurs as both an A and a B number:$$\begin{align} 13482 + 14832 = \textbf{28314}\\13824 + \textbf{28314} = 42138 \end{align}$$

Friday, 10 April 2026

Multiplicative and Additive Digital Roots

Even though I've written about multiplicative and arithmetic digital roots in numerous posts, it would seem that I've never addressed the obvious question of how many numbers have identical roots. I was searching for properties of the number associated with my diurnal age (28131) when I noticed the following:$$ \begin{align} 28131 &\rightarrow 2 + 8 + 1+3+1 = 15 \rightarrow 1 + 5 =6 \\ 28131 &\rightarrow 2 \times 8 \times 1 \times 3 \times 1 =48 \rightarrow 4 \times 8 =32 \rightarrow 3 \times 2 = 6 \end{align}$$It turns out that there are \( \textbf{1085} \) such numbers in the range between 1 and 40000, representing 2.7125% of the range. I won't list all of the numbers here but only those from my diurnal age up to 40000 (permalink):

28131, 28167, 28169, 28176, 28178, 28187, 28196, 28223, 28232, 28311, 28322, 28347, 28374, 28437, 28473, 28617, 28619, 28671, 28691, 28716, 28718, 28734, 28743, 28761, 28781, 28817, 28871, 28916, 28961, 29117, 29126, 29162, 29168, 29171, 29186, 29216, 29261, 29612, 29618, 29621, 29681, 29711, 29816, 29861, 29999, 31113, 31128, 31131, 31139, 31169, 31182, 31193, 31196, 31218, 31227, 31234, 31243, 31272, 31281, 31311, 31319, 31324, 31342, 31344, 31391, 31423, 31432, 31434, 31443, 31619, 31677, 31691, 31722, 31767, 31776, 31778, 31787, 31812, 31821, 31877, 31889, 31898, 31913, 31916, 31931, 31961, 31988, 32118, 32127, 32134, 32143, 32172, 32181, 32217, 32226, 32228, 32262, 32271, 32282, 32314, 32336, 32341, 32363, 32413, 32431, 32478, 32487, 32622, 32633, 32712, 32721, 32748, 32784, 32811, 32822, 32847, 32874, 33111, 33119, 33124, 33142, 33144, 33191, 33214, 33236, 33241, 33263, 33326, 33344, 33362, 33412, 33414, 33421, 33434, 33441, 33443, 33477, 33479, 33497, 33557, 33575, 33623, 33632, 33666, 33747, 33749, 33755, 33774, 33794, 33911, 33947, 33974, 34123, 34132, 34134, 34143, 34213, 34231, 34278, 34287, 34312, 34314, 34321, 34334, 34341, 34343, 34377, 34379, 34397, 34413, 34431, 34433, 34728, 34737, 34739, 34773, 34782, 34793, 34827, 34872, 34937, 34973, 35357, 35375, 35537, 35573, 35735, 35753, 36119, 36177, 36191, 36222, 36233, 36323, 36332, 36366, 36636, 36663, 36717, 36771, 36911, 37122, 37167, 37176, 37178, 37187, 37212, 37221, 37248, 37284, 37347, 37349, 37355, 37374, 37394, 37428, 37437, 37439, 37473, 37482, 37493, 37535, 37553, 37617, 37671, 37716, 37718, 37734, 37743, 37761, 37781, 37817, 37824, 37842, 37871, 37934, 37943, 38112, 38121, 38177, 38189, 38198, 38211, 38222, 38247, 38274, 38427, 38472, 38717, 38724, 38742, 38771, 38819, 38891, 38918, 38981, 39113, 39116, 39131, 39161, 39188, 39311, 39347, 39374, 39437, 39473, 39611, 39734, 39743, 39818, 39881

All permutations of any of these numbers will have multiplicative and arithmetic digital roots that are the same. Putting the digits of 28131 in ascending order, we get 11238. If we only consider numbers whose digits are in ascending order, then in the range up to 40000 there are only \( \textbf{74}\) numbers that qualify. These are:

1, 2, 3, 4, 5, 6, 7, 8, 9, 22, 123, 137, 139, 168, 179, 188, 233, 267, 299, 346, 389, 899, 1124, 1157, 1347, 1355, 1469, 1779, 1788, 2236, 2346, 2348, 2778, 3335, 3779, 11126, 11133, 11148, 11177, 11222, 11238, 11279, 11339, 11369, 11579, 11666, 11677, 11679, 11699, 11999, 12237, 12269, 12334, 12444, 12446, 12678, 12689, 12777, 12788, 13344, 13677, 13778, 13889, 14777, 22236, 22238, 23336, 23478, 29999, 33344, 33477, 33479, 33557, 33666

Permutations of the digits of these numbers will generate the other 1011 (1085 - 74) numbers in the range. These numbers are members of OEIS A064702.

Friday, 3 April 2026

77th Birthday

Today I turned 77 years of age and my equivalent diurnal age is 28124 which has the following factorisation:$$28124=2 \times 2 \times 79 \times 89$$Though this number is composite, it has numerous prime number associations. Let's examine some of them beginning with its sum of digits, sum of digits squares and sum of digits cubed:$$ \begin{align} 2 + 8 + 1 + 2 + 4 &=17 \text{ (prime)} \\2^2+8^2+1^2+2^2+8^4 &= 89 \text{ (prime)} \\2^3+8^3+1^3+2^3+8^3 &= 593 \text{ (prime)} \end{align}$$The number is only one step removed from its home prime because:$$28124=2 \times 2 \times 79 \times 89 \rightarrow 227989 \text{ (prime)}$$The number is also a member of OEIS A048381: numbers such that replacing each nonzero digit with the n-th prime (replacing each 0 digit with a 1) yields a prime. Thus:$$28124 \rightarrow 319237 \text{ (prime)}$$The number has a binary complement that is prime. The binary complement of a number is determined by changing the number to binary and swapping any 0's for 1's and vice versa. Thus:$$ \begin{align} 28124_{10} &= 110110111011100_2 \\ &\rightarrow 001001000100011_2 \\ &=4643_{10} \text{ (prime)} \end{align}$$The number is quickly captured by the prime 28109 under the ODD(+) and EVEN(-) algorithm where the sum of the odd digits is added to the number and the sum of the even digits is subtracted recursively until a fixed point is reached or a loop is entered. Here is the trajectory is simply:$$ \begin{align} 28124 &\rightarrow 28124 + 1 -(2 + 8 + 2 + 4) \\ &=28124 + 1 - 16 \\ &=28109 \text{ (prime)} \end{align}$$The number can be considered as a concatenation of powers of the prime 2 because:$$ 28124 = 2^1\, | \,2^3 \,| \,2^0 \,| \,2^1 \,| \, 2^2 $$where | represents concatenation. The number can be generated by adding the prime sum (13) of the digits of the prime 28111 to itself. Thus:$$28111+13=28124$$The digits of the number can be rearranged to form the following primes:$$22481, 24281, 24821, 42281, 42821, 48221, 82241, 82421, 84221$$The position 28124 in the Recaman Sequence is reached after a prime number of iterations:$$0 \rightarrow 28124 \text{ requires } 34183 \text{ (prime) iterations}$$

Thursday, 14 August 2025

Coding and Integers

The thought struck me to write a program that looked at all base 10 numbers in the range from 10 to 40000 that, when converted to a number base between 2 and 9, returned a number with the same digits as the base 10 number but in a different order. It's a simple enough program to write in SageMath and this is what I created originally:

T=[("number","permutation","base")]
T.append(("","",""))
for n in [10..40000]:
    for b in [2..9]:
        number=int(n.str(base=b))
        if sorted(n.digits())==sorted(number.digits()):
            L.append(n)
            T.append((n,n.str(base=b),b))
print(L)
print(len(L))
print()
print(table(T))

The program will not run because there is a problem with "sorted(number.digits())". I get the error message "AttributeError: 'int' object has no attribute 'digits' ". I know from experience how to fix the problem. I simply replace "int" with "Integer" but I've never fully understood why this change is necessary. I queried Gemini and it came up with the following explanation:

Of course. Your code requires SageMath's Integer type because it uses special mathematical methods that Python's standard int type doesn't have.

The specific line of code that causes the issue is if sorted(n.digits())==sorted(number.digits()):.


SageMath's Integer vs. Python's int

Think of Python's built-in int as a basic calculator and SageMath's Integer as a powerful scientific calculator. While both can store whole numbers, the SageMath version comes with a lot of extra functions built specifically for number theory and advanced mathematics.

Python int: A standard data type for storing whole numbers. It's great for general programming, loops, and basic arithmetic. However, it does not have a built-in method called .digits().
SageMath Integer: A more specialized object. It's designed for mathematical computation and has many useful methods, including:
.digits(): Returns a list of the number's digits.
.str(base=b): Returns the string representation of the number in a given base.
.is_prime(): Checks if the number is prime.
.divisors(): Returns a list of the number's divisors.

Why Your Code Fails with int

In your loop, the variable n is a SageMath Integer because it's created by SageMath's range notation ([10..40000]).
When you write number = int(n.str(base=b)), you successfully convert the base-b string representation of n into a standard Python int and store it in the number variable.
The program then fails at the next line: sorted(number.digits()). Since number is a plain Python int, it doesn't have the .digits() method, and SageMath throws an AttributeError.

Why Your Code Works with Integer

When you use number = Integer(n.str(base=b)), you are using SageMath's Integer constructor.
This creates a SageMath Integer object and stores it in the number variable.
Now, when the program reaches sorted(number.digits()), the call is valid because SageMath Integer objects do have the .digits() method. 👍

In short, you must use Integer to ensure that both n and number are SageMath objects that understand the special mathematical methods your algorithm relies on.

So now I know. So what is the output from my program when it is run? It turns out that there are 76 numbers that satisfy and they are (permalink):

13, 23, 46, 158, 227, 265, 316, 445, 1030, 1045, 1135, 1234, 1236, 1273, 1366, 1380, 1431, 1454, 1653, 2027, 2060, 2116, 2154, 2315, 2534, 3160, 3161, 3162, 3163, 3164, 3165, 3166, 3167, 3226, 5270, 5567, 5637, 5783, 10144, 10235, 10342, 10453, 10542, 11425, 11750, 12415, 12450, 12564, 12651, 13045, 13245, 13260, 13402, 13534, 13620, 14610, 15226, 15643, 16255, 16273, 16546, 16633, 21322, 21753, 21763, 21835, 23568, 26804, 30576, 31457, 32348, 34582, 35001, 35081, 35228, 37465

These numbers are the initial members of OEIS A090144 (I've discounted the trivial numbers from 1 to 8). Here are the details:

  number   permutation   base
  13       31            4
  23       32            7
  46       64            7
  158      185           9
  227      272           9
  265      526           7
  316      631           7
  445      544           9
  1030     3001          7
  1045     4501          6
  1135     5131          6
  1234     3412          7
  1236     1623          9
  1273     2371          8
  1366     3661          7
  1380     1803          9
  1431     4113          7
  1454     4145          7
  1653     3165          8
  2027     2702          9
  2060     6002          7
  2116     6112          7
  2154     4152          8
  2315     3152          9
  2534     3425          9
  3160     6130          8
  3161     6131          8
  3162     6132          8
  3163     6133          8
  3164     6134          8
  3165     6135          8
  3166     6136          8
  3167     6137          8
  3226     6232          8
  5270     7205          9
  5567     7565          9
  5637     7653          9
  5783     7835          9
  10144    41401         7
  10235    15032         9
  10342    42103         7
  10453    15304         9
  10542    42510         7
  11425    45211         7
  11750    17105         9
  12415    51124         7
  12450    51204         7
  12564    51426         7
  12651    51612         7
  13045    53014         7
  13245    53421         7
  13260    20163         9
  13402    20341         9
  13534    54313         7
  13620    20613         9
  14610    60411         7
  15226    62251         7
  15643    63415         7
  16255    65251         7
  16273    37621         8
  16546    66145         7
  16633    66331         7
  21322    32221         9
  21753    52371         8
  21763    32761         9
  21835    32851         9
  23568    35286         9
  26804    40682         9
  30576    73560         8
  31457    75341         8
  32348    48332         9
  34582    52384         9
  35001    53010         9
  35081    53108         9
  35228    53282         9
  37465    56347         9