Showing posts with label reversible. Show all posts
Showing posts with label reversible. Show all posts

Monday, 28 September 2026

Tetraprimes

While I have looked at numbers with four prime factors counted with multiplicity whose reversals also have this property, I've not actually looked at reversible tetraprimes. Numbers with four distinct prime factors are called tetraprimes. The first example of such a number is 1518 where we have:

  • \(1518 = 2 \times 3 \times 11 \times 23 \)
  • \( 8151 = 3 \times 11 \times 13 \times 19 \)
There are 273 such numbers in the range up to 40000 (permalink):

1518, 2046, 2226, 2262, 2418, 2478, 2618, 2622, 2814, 2838, 2886, 3135, 3927, 4170, 4182, 4386, 4389, 4746, 4785, 4935, 5313, 5394, 5406, 5478, 5565, 5655, 5838, 5874, 6018, 6045, 6222, 6402, 6438, 6474, 6486, 6690, 6699, 6834, 6846, 6882, 7293, 7458, 8106, 8142, 8151, 8162, 8346, 8382, 8385, 8547, 8742, 8745, 9834, 9966, 10434, 10506, 11022, 11346, 11814, 11946, 12243, 12441, 12738, 12765, 13026, 13299, 13542, 13629, 13695, 14105, 14118, 14421, 14469, 14574, 15114, 15873, 16005, 16107, 16359, 16665, 16786, 16962, 16995, 17017, 17358, 17589, 17655, 17754, 17922, 18183, 18258, 18447, 18462, 18546, 18615, 18879, 19434, 19437, 19446, 19578, 19662, 20022, 20055, 20085, 20118, 20145, 20163, 20190, 20262, 20310, 20355, 20382, 20405, 20526, 20553, 20559, 20562, 20658, 20746, 20769, 20774, 20878, 20922, 20958, 22002, 22011, 22074, 22098, 22154, 22242, 22290, 22458, 22515, 22533, 22578, 22695, 22710, 22737, 22755, 22854, 22902, 22946, 22962, 22971, 24115, 24123, 24178, 24186, 24198, 24222, 24270, 24297, 24339, 24465, 24530, 24531, 24582, 24585, 24618, 24645, 24662, 24717, 24766, 24846, 24890, 24906, 24915, 24969, 26013, 26103, 26106, 26187, 26202, 26286, 26358, 26394, 26445, 26481, 26490, 26502, 26535, 26554, 26634, 26642, 26691, 26733, 26895, 26922, 26961, 26978, 26985, 26994, 28083, 28086, 28194, 28245, 28302, 28329, 28410, 28446, 28455, 28497, 28509, 28542, 28545, 28578, 28623, 28626, 28635, 28785, 28866, 28886, 28905, 28974, 28985, 28990, 30162, 30426, 31038, 31062, 31146, 31494, 31515, 31614, 31955, 32142, 32574, 32637, 32682, 32745, 32835, 32865, 33198, 33285, 33522, 33594, 33654, 33666, 33762, 34017, 34221, 34386, 34419, 34518, 34554, 34626, 34854, 35502, 35673, 35706, 35826, 36102, 36195, 36218, 36645, 36966, 36993, 37037, 37074, 37158, 37365, 37605, 37653, 37785, 37851, 38055, 38082, 38181, 38445, 39045, 39666, 39738, 39963

I've also considered biprimes as rectangles and triprimes as rectangular prisms but what about tetraprimes. I asked Gemini the following:
A triprime with prime factors of \(a\), \(b\) and \(c\) can be conceived of as a rectangular prism with sides \(a\), \(b\), \(c\), volume \(a \, b \, c\) and surface area equal to \(2 \times (ab + bc + ac) \). Are there equivalent formulae for volume and surface area of a four dimensional object derived from a tetraprime with four prime factors.

Here was Gemini's response:

The direct geometrical equivalent of a tetraprime with four prime factors \(a\), \(b\), \(c\), and \(d\) is a four-dimensional rectangular orthotope (commonly called a hyperrectangle).

Because a 4D object possesses boundaries in multiple lower dimensions (3D, 2D, and 1D), the equivalent to your 3D formulas expands into a hierarchy of measurements. Just as a 3D prism is bounded by 2D faces, a 4D orthotope is bounded by 3D cells, 2D faces, and 1D edges.

Here are the equivalent geometric formulas derived from a tetraprime:

  • 4D Hypervolume (The equivalent of 3D Volume): The total 4D spatial content of the object is simply the product of all four prime factors, which is exactly equal to the tetraprime itself.$$V_4 = a \cdot b \cdot c \cdot d$$

  • 3D Surface Volume (The structural equivalent of 3D Surface Area): In 3D geometry, "surface area" measures the (n-1)-dimensional boundary of the object. For a 4D object, its outer boundary is three-dimensional. A hyperrectangle is enclosed by 8 solid 3D rectangular prisms (called "cells"). There are two cells for each possible triplet of the dimensions.$$S_3 = 2(abc + abd + acd + bcd)$$

  • 2D Total Face Area (The literal equivalent of 2D Area): If you are looking specifically for flat, two-dimensional surface area, a hyperrectangle has 24 flat 2D rectangular faces. For every pair of dimensions, there are 4 identical faces throughout the 4D structure.$$A_2 = 4(ab + ac + ad + bc + bd + cd)$$

  • 1D Total Edge Length: For complete geometric breakdown, a hyperrectangle has 32 one-dimensional edges. There are 8 parallel edges for each of the four prime factors.$$L_1 = 8(a + b + c + d)$$

By substituting your four prime factors into \(V_4\) and \(S_3\), you achieve the exact mathematical analogies for volume and surface area as you step up from three dimensions into four.

I'll investigate this further in a subsequent blog.

Wednesday, 19 August 2026

Super Sphenic Numbers

The number associated with my diurnal age today (28262) is what might be termed a "super sphenic number" as I'll explain in this post. Firstly however, its factorisation:$$28262=2 \times 13 \times 1087$$If we reverse its digits, we get the number 26282 and this number is also sphenic:$$26282 = 2 \times 17 \times 773$$Let's now concatenate the factors of 28262 in ascending order. This gives us the number 2131087 which is also sphenic:$$2131087 = 7 \times 167 \times 1823$$28262 has a sum of digits of 20 and if we add this to the original number we get the palindromic number 28282 which is also sphenic:$$28262+20=28282 = 2 \times 79 \times 179$$The number has a product of digits of 384 and if we subtract this from the original number we get 27878 which is sphenic:$$28262 - 384 = 27878 = 2 \times 53 \times 263$$If we consider only the internal digits of 28262, we get the number 826 which is also sphenic:$$2\, 826 \, 2 \rightarrow826=2 \times 7 \times 59$$When a sphenic number is considered as a sphenic brick then it has an associated number in the form of the brick's surface area. In the case of 28262, this associated surface area is 32662 square units and this number too is sphenic:$$32662 = 2 \times 7 \times 2333$$28262 has a sum of proper divisors that is also sphenic:$$ \sigma(28262) - 28262 =17434 = 2 \times 23 \times 379 $$The number has a sum of prime factors (1102) that is sphenic:$$2 +13+1087=1102 = 2 \times 19 \times 29$$28262 has a totient of 13032 which is not sphenic but its cototient (number - totient) of 15230 is:$$28262 - 13032 = 15230 = 2 \times 5 \times 1523$$So we can see that 28262 may well be termed a super sphenic number because of the above associations.

Monday, 15 December 2025

Emirpimes In Bases Greater Than 10

Why stop at bases between 2 and 9? I prompted Gemini again:

Can this program be modified so that it can investigate numbers in bases from 11 to 16? I know this is more difficult because of the necessary use of letters as well as the digits from 0 to 9.  

The program that it came up with works in bases from 2 to 36 which is impressive. I'll include the code and Gemini's explanation of it after the tables that cover bases of 11, 12, 13, 14, 15 and 16.

BASE 11


Table 1: permalink

BASE 12


Table 2: permalink

BASE 13


Table 3: permalink

BASE 14


Table 4: permalink

BASE 15


Table 5: permalink

BASE 16


Here is the code and what Gemini had to say about it. 

Yes, this can definitely be done. The core logic of the mathematics (checking primes and reversing lists of numbers) remains exactly the same. The only complexity is visual: we need to translate the internal numbers (10, 11, 12, etc.) into their representative symbols (A, B, C, etc.) so they are readable in the output.

Here is the upgraded program. It now includes a DIGIT_MAP to handle bases up to 16 (and actually up to 36, if you wanted to go higher).

The Upgraded Python Program (Bases 2–16)

Python
# ==========================================
#  CONFIGURATION (User Inputs)
# ==========================================
SEARCH_BASE = 16          # Supports bases 2 through 16
SEARCH_RANGE = (1, 60000) # Range to search [start, end]

# ==========================================
#  CORE FUNCTIONS
# ==========================================

# Standard mapping for bases > 10
DIGIT_MAP = "0123456789ABCDEF"

def to_base(n, b):
    """Converts an integer n to a list of digit values in base b."""
    if n == 0:
        return [0]
    digits = []
    while n:
        digits.append(int(n % b))
        n //= b
    return digits[::-1]

def from_base(digits, b):
    """Converts a list of digit values in base b back to an integer."""
    n = 0
    for d in digits:
        n = n * b + d
    return n

def get_reversed_val(n, b):
    """Returns the integer value of n with its digits reversed in base b."""
    digits = to_base(n, b)
    # We reverse the list of values (e.g. [1, 15] becomes [15, 1])
    return from_base(digits[::-1], b)

def is_prime(n):
    """Efficient primality test."""
    if n <= 1: return False
    if n <= 3: return True
    if n % 2 == 0 or n % 3 == 0: return False
    i = 5
    while i * i <= n:
        if n % i == 0 or n % (i + 2) == 0:
            return False
        i += 6
    return True

def get_semiprime_factors(n):
    """
    Returns [p, q] if n is a semiprime.
    Returns None otherwise.
    """
    factors = []
    d = 2
    temp = n
    # Optimization: limit search to sqrt(temp)
    while d * d <= temp:
        while temp % d == 0:
            factors.append(d)
            temp //= d
            if len(factors) > 2: 
                return None
        d += 1
    if temp > 1:
        factors.append(temp)
    
    if len(factors) == 2:
        return factors
    return None

def format_in_base(n, b):
    """
    Returns string representation of n in base b using 0-9 and A-F.
    """
    digits = to_base(n, b)
    # Map integer values (e.g., 10) to characters (e.g., 'A')
    return "".join(DIGIT_MAP[d] for d in digits)

# ==========================================
#  MAIN EXECUTION
# ==========================================

print(f"Searching for special Emirpimes in Base {SEARCH_BASE} between {SEARCH_RANGE}...")
print(f"Format: Base 10 | Base {SEARCH_BASE} | Factors (Base {SEARCH_BASE}) | Reversed (Base {SEARCH_BASE}) | Rev Factors (Base {SEARCH_BASE})")
print(f"{'-'*110}")

count = 0
start, end = SEARCH_RANGE

for n in range(start, end + 1):
    # 1. Check if semiprime
    factors = get_semiprime_factors(n)
    if not factors:
        continue
    
    p, q = factors[0], factors[1]
    
    # 2. Get reversed values in the target base
    n_rev_val = get_reversed_val(n, SEARCH_BASE)
    p_rev_val = get_reversed_val(p, SEARCH_BASE)
    q_rev_val = get_reversed_val(q, SEARCH_BASE)
    
    # 3. Check Condition 1: Factors must be 'Emirps' in this base
    # (Reversed factors must be prime)
    if not (is_prime(p_rev_val) and is_prime(q_rev_val)):
        continue
        
    # 4. Check Condition 2: The "Special" Multiplication Property
    # Rev(n) == Rev(p) * Rev(q)
    if n_rev_val == (p_rev_val * q_rev_val):
        
        # Prepare output strings using the Alpha-Numeric formatter
        n_str = format_in_base(n, SEARCH_BASE)
        p_str = format_in_base(p, SEARCH_BASE)
        q_str = format_in_base(q, SEARCH_BASE)
        
        n_rev_str = format_in_base(n_rev_val, SEARCH_BASE)
        p_rev_str = format_in_base(p_rev_val, SEARCH_BASE)
        q_rev_str = format_in_base(q_rev_val, SEARCH_BASE)
        
        factors_str = f"{p_str} x {q_str}"
        rev_factors_str = f"{p_rev_str} x {q_rev_str}"

        # Print formatted columns
        print(f"{n:<10} | {n_str:<10} | {factors_str:<20} | {n_rev_str:<20} | {rev_factors_str:<20}")
        count += 1

print(f"{'-'*110}")
print(f"Found {count} special emirpimes in Base {SEARCH_BASE}.")

Key Improvements

  1. DIGIT_MAP = "0123456789ABCDEF": This string acts as a lookup table. If a digit value is 15, the code looks at index 15 and retrieves 'F'.

  2. format_in_base: This function was rewritten to use the lookup table, ensuring that any number from 10 to 15 is printed as a letter.

  3. Universal Logic: This version works for any base from 2 to 16 without needing further changes. You simply change SEARCH_BASE = 16, 12, or 8 at the top.

Example: What to expect in Base 16 (Hexadecimal)

If you run this with SEARCH_BASE = 16, you might see results involving the digit 'A' (10) or 'C' (12), provided the "no carrying" rule is met.

  • Example: If we had $13 \times 13 = 169$ in Base 10, in Base 16 this is $D \times D = A9$.

  • Since $D$ (13) is a single digit, reversing it changes nothing, so it acts like a palindrome.

  • However, finding multi-digit primes in Base 16 that don't "carry" when multiplied is harder because the "digits" are larger, but the slots fill up differently.