21
\$\begingroup\$

easy mode of my previous challenge

A perfect number is a positive integer whose sum of divisors (except itself) is equal to itself. E.g. 6 (1 + 2 + 3 = 6) and 28 (1 + 2 + 4 + 7 + 14 = 28) are perfect.

A sublime number (OEIS A081357) is a positive integer whose count and sum of divisors (including itself) are both perfect. E.g. 12 is a sublime number because:

  • the divisors of 12 are 1, 2, 3, 4, 6, 12
  • the count of divisors is 6 (perfect)
  • the sum of divisors is 28 (perfect)

The next smallest known sublime number is

6086555670238378989670371734243169622657830773351885970528324860512791691264

which is a product of a power of 2 and six Mersenne primes

$$ 2^{126}(2^3-1)(2^5-1)(2^7-1)(2^{19}-1)(2^{31}-1)(2^{61}-1) $$

These two numbers are the only known sublime numbers as of 2022. The necessary and sufficient conditions for even sublime numbers have been found in this paper (pdf), but it remains unknown whether odd sublime numbers exist.

It is known that there are no other even sublime numbers before the number, but it is not known whether there are any odd ones.

Task

Output the second even sublime number shown above. It is OK to only theoretically output this number in the following ways:

  • the program outputs the correct number with probability 1 in finite time
  • the program outputs the correct number given enough time and unlimited memory
  • the program would output the correct number if the native number type had infinite precision

Standard rules apply. The shortest code in bytes wins.

\$\endgroup\$
6
  • \$\begingroup\$ @thejonymyster It is known that there are no other even sublime numbers below that number. \$\endgroup\$
    – Bubbler
    Aug 26, 2022 at 1:10
  • \$\begingroup\$ So... I'm wondering that... Is there any built-in in Mathematica output this? \$\endgroup\$
    – tsh
    Aug 26, 2022 at 6:36
  • \$\begingroup\$ ///, 76 bytes, optimal solution: 6086555670238378989670371734243169622657830773351885970528324860512791691264 \$\endgroup\$ Aug 26, 2022 at 17:19
  • \$\begingroup\$ "the program outputs the correct number with probability 1 in finite time": do you mean to imply as well that there is no other output? \$\endgroup\$ Aug 27, 2022 at 0:50
  • \$\begingroup\$ @GregMartin I think other output will be considered a loophole. See codegolf.meta.stackexchange.com/a/9447/55372 \$\endgroup\$
    – pajonk
    Aug 28, 2022 at 10:57

22 Answers 22

8
\$\begingroup\$

PARI/GP, 45 bytes

print(vecprod([4^i-2^i|i<-[3,5,7,19,31,61]]))

Attempt This Online!

The number is \$\prod_{i\in\{3,5,7,19,31,61\}}(4^i-2^i)\$. In fact, \$126=3+5+7+19+31+61\$.

Another interesting fact is that \$2^{126}\$ is just the sum of divisors of \$\prod_{i\in\{3,5,7,19,31,61\}}(2^i-1)\$. This might be useful for some golfing language if there is a built-in for divisor sum.

\$\endgroup\$
7
\$\begingroup\$

Python 2, 37 bytes

print~-2**31*~-2**61*14448825433<<126

Try it online!

Writes out \$2^{31}-1\$, \$2^{61}-1\$, and the bit-shift \$2^{126}\$, and hardcodes the remaining product.

\$\endgroup\$
7
\$\begingroup\$

R, 33 32 bytes

Edit -1 byte thanks to @xnor.

prod(8^42,2^c(3,5,7,19,31,61)-1)

Try it online!

Spells out the product.

@alephalpha's approach lead to +1 byte for me, but @Dominic van Essen found a 32-byte version (see the footer of the TIO link above).

\$\endgroup\$
3
  • \$\begingroup\$ You can do 8^42 for 2^126 \$\endgroup\$
    – xnor
    Aug 26, 2022 at 4:36
  • \$\begingroup\$ @xnor ah, right, thanks! \$\endgroup\$
    – pajonk
    Aug 26, 2022 at 6:24
  • 1
    \$\begingroup\$ (alephalpha's approach could be the same length: try it)... \$\endgroup\$ Mar 27 at 8:48
5
\$\begingroup\$

05AB1E, 13 11 bytes

•w4н•foD<*P

-2 bytes thanks to @alephalpha.

Try it online.

Explanation:

•w4н•        # Push compressed integer 3772545
     f       # Get its prime factors: [3,5,7,19,31,61]
      o      # Get 2 to the power for each of these integers
       D     # Duplicate the list
        <    # Decrease each by 1 in the copy
         *   # Multiply the values at the same positions in the two lists
          P  # Get the product of this list
             # (after which the result is output implicitly)

See this 05AB1E tips of mine (section How to compress large integers?) to understand why •w4н• is 3772545.

\$\endgroup\$
2
  • 1
    \$\begingroup\$ -2 bytes: •w4н•foD<*P \$\endgroup\$
    – alephalpha
    Aug 26, 2022 at 8:28
  • \$\begingroup\$ @alephalpha Ah, of course. Thanks! :) \$\endgroup\$ Aug 26, 2022 at 8:32
5
\$\begingroup\$

Pyth, 20 19 16 15 bytes

*FsmtB^2dPC"9

Try it online!

*FsmtB^2dPC"9
          C"9  # compressed 3772545
         P     # prime factors (3, 5, 7, 19, 31, 61)
   mtB^2d      # map d: [2**d, 2**d - 1]
  s            # flatten
*F             # reduce on multiplication

-3 bytes thanks to @CursorCoercer
-1 byte thanks to @isaacg

\$\endgroup\$
2
  • 1
    \$\begingroup\$ Save 3 bytes by replacing .U*bZ with *F \$\endgroup\$ Aug 26, 2022 at 16:18
  • 1
    \$\begingroup\$ Save 1 byte by replacing m-^4d^2d with smtB^2d \$\endgroup\$
    – isaacg
    Aug 28, 2022 at 0:52
4
\$\begingroup\$

Vyxal, 14 13 11 bytes

»;⟑L»ǐE:‹*Π

Try it Online!

-1 byte thanks to alephalpha and -2 bytes thanks to Mukundan314.

Jelly, 17 16 bytes

“¤¦¬Œþ=‘2*’æ«21P

Try it online!

-1 byte thanks to xnor.

\$\endgroup\$
6
  • \$\begingroup\$ Might it be shorter to multiply each list element by 2^21 instead of the bit-shift at the end? \$\endgroup\$
    – xnor
    Aug 26, 2022 at 1:19
  • \$\begingroup\$ @xnor It's 2^126, and it's longer (“¤¦¬Œþ=‘2*’P×2*126¤) \$\endgroup\$
    – naffetS
    Aug 26, 2022 at 1:35
  • \$\begingroup\$ I meant to multiply each element of [7, 31, 127, 524287, 2147483647, 2305843009213693951] by 2^21 (probably via bit-shift) so that when we take their product, we've included an overall factor of (2^21)^6=2^126. \$\endgroup\$
    – xnor
    Aug 26, 2022 at 1:42
  • \$\begingroup\$ Ah, clever. That saves a byte on the Jelly answer (not on Vyxal because 126 could be compressed). Thanks! \$\endgroup\$
    – naffetS
    Aug 26, 2022 at 1:44
  • \$\begingroup\$ -1 byte for Vyxal. \$\endgroup\$
    – alephalpha
    Aug 26, 2022 at 2:51
4
\$\begingroup\$

Factor + math.unicode,  40 38 bytes

4 2 [ "=">array n^v ] bi@ v- Π .

Try it online!

-2 bytes from porting @alephalpha's PARI/GP answer.

Note "=" is a literal string that is equivalent to { 3 5 7 19 31 61 }. You can only see the = since the rest are non-printable, but you can see the non-printable characters on TIO. This needs to be converted to an array because n^v is buggy otherwise. Still 4 bytes shorter than the sequence literal.

  • 4 2 [ ... ] bi@ Apply [ ... ] to both 4 and 2.
  • { 3 5 7 19 31 61 } n^v Input raised to 3, input raised to 5, etc.
  • v- Subtract two vectors.
  • Π Take the product.
  • . Print the result to stdout.
\$\endgroup\$
4
\$\begingroup\$

Bash, 47 Bytes

echo "14448825433*(2^31-1)*(2^61-1)*(2^126)"|bc

Try it online!

\$\endgroup\$
3
\$\begingroup\$

Wolfram Language (Mathematica), 32 bytes

8^42##&@@(2^{3,5,7,19,31,61}-1)&

Try it online!

\$\endgroup\$
3
+100
\$\begingroup\$

Prolog (SWI), 51 bytes

Thanks JoKing and Steffan for helping me golf some bytes

?-X is(2^61-1)*14448825433*(2^31-1)*2^126,write(X).

Try it online!

My very first Prolog answer :D, probably can be golfed a lot though.

\$\endgroup\$
4
  • \$\begingroup\$ you can just do write(X). \$\endgroup\$
    – naffetS
    Sep 2, 2022 at 1:02
  • \$\begingroup\$ also you can change X is 14448825433*(2^61-1) to X is(2^61-1)*14448825433 to save a byte. unfortunately it's the same length to use format: ?-format("~d",(2^61-1)*14448825433*(2^31-1)*2^126). \$\endgroup\$
    – naffetS
    Sep 2, 2022 at 1:02
  • \$\begingroup\$ @Steffan ah ok didn't know that, will fix \$\endgroup\$
    – Aiden Chow
    Sep 2, 2022 at 1:02
  • \$\begingroup\$ @Steffan ok that format trick is cool \$\endgroup\$
    – Aiden Chow
    Sep 2, 2022 at 1:04
2
\$\begingroup\$

Charcoal, 21 bytes

IΠEX²⁻E357COm℅ι⁴⁸×ι⊖ι

Try it online! Link is to verbose version of code. Explanation:

       357COm           Literal string `357COm`
      E                 Map over characters
              ι         Current character
             ℅          ASCII code
     ⁻                  Vectorised subtract
               ⁴⁸       Literal integer `48`
   X                    Vectorised exponentiate with base
    ²                   Literal integer `2`
  E                     Map over powers of `2`
                    ι   Current power of `2`
                   ⊖    Decremented
                 ×      Multiplied by
                  ι     Current power of `2`
 Π                      Take the product
I                       Cast to string
                        Implicitly print
\$\endgroup\$
2
\$\begingroup\$

MathGolf, 15 bytes

357HT╟)]ó_(m*ε*

Try it online.

Explanation:

3        # Push 3
 5       # Push 5
  7      # Push 7
   H     # Push 19
    T    # Push 31
     ╟   # Push 60
      )  # Increase the 60 by 1
       ] # Wrap the stack into a list: [3,5,7,19,31,61]
ó        # Calculate 2 to the power each of these integers
 _       # Duplicate the list
  (      # Decrease each by 1
   m*    # Multiply the values at the same positions in the lists together
     ε*  # Product: reduce by multiplication
         # (after which the entire stack joined together is output implicitly as result)
\$\endgroup\$
2
\$\begingroup\$

MATL, 21 19 18 14 bytes

3772545YfWtqhp

Try it online!

3772545YfWtqhp
3772545Yf         # Prime factorize 3772545 (3, 5, 7, 19, 31, 61)
         W        # 2 ** elements
          t       # duplicate list
           q      # decrement elements in copy by 1
            h     # concatenate lists 
             p    # product

-2 bytes thanks to @Luis Mendo

\$\endgroup\$
0
2
\$\begingroup\$

Nibbles, 16 15 12.5 bytes

`*.`D62*;^2$-$~ a8532dc3

Attempt This Online!

-2.5 bytes thanks to Dominic van Essen

Nibbles has no prime-related built-ins, so I had to resort to good old base conversion.

`*.`D62*;^2$-$~ a8532dc3
`*                       Product
  .                       for each n in
   `D62                    convert from base 62
                a8532dc3    2824023491
       *                   multiply
         ^2                 2 to the power of
           $                 n
        ;    $              with itself
            - ~              minus 1
\$\endgroup\$
3
  • 1
    \$\begingroup\$ 14 bytes \$\endgroup\$ Mar 27 at 8:27
  • 1
    \$\begingroup\$ 12.5 bytes \$\endgroup\$ Mar 27 at 8:32
  • \$\begingroup\$ @DominicvanEssen Nice, I didn't notice that the 126 is the sum of the exponents. Thanks! \$\endgroup\$
    – xigoi
    Mar 27 at 9:40
1
\$\begingroup\$

Burlesque, 33 bytes

{Jfc~]++==}s1r1f{fcsa%1!j++%1!&&}

Try it online!

Given infinite time, should find sublime numbers

{    # IsPerfect function
 J   # Duplicate
 fc  # Factors
 ~]  # Without self
 ++  # Sum
 ==  # Equals self
}s1  # Store as "1"
r1   # Range 1..inf
f{   # Filter
 fc  # Factors
 sa  # Non-destructive Length
 %1! # IsPerfect
 j++ # Sum of factors
 %1! # IsPerfect
 &&  # And
}
\$\endgroup\$
1
\$\begingroup\$

Vyxal, 16 13 bytes

₆¨*≬K₍L∑¨=∆Kc

Try it Online!

half-Legitimate calculation is was shorter than hard coding lol. Given enough time and memory, this would eventually output the right number.

Explained

₆¨*≬K₍L∑¨=∆Kc
₆¨*≬        c   # From all multiples of 64 (which contains the target number), get the first where:
    K₍L∑        #   The list [len(factors), sum(factors)]
        ¨=∆K    #   Is invariant under sum of proper divisors
\$\endgroup\$
5
  • \$\begingroup\$ If the code means "last of the first two integers that are sublime", it isn't correct because there might be an unknown odd sublime number before the 2nd even one. \$\endgroup\$
    – Bubbler
    Aug 26, 2022 at 0:38
  • \$\begingroup\$ @Steffan That was exactly the initial version of this answer and my first comment explains why it doesn't work. \$\endgroup\$
    – Bubbler
    Aug 26, 2022 at 1:01
  • 1
    \$\begingroup\$ You could speed things up slightly by replacing with , because the target number is a multiple of 256. \$\endgroup\$
    – naffetS
    Aug 26, 2022 at 1:02
  • \$\begingroup\$ It's no longer shorter than hardcoding it :P \$\endgroup\$
    – naffetS
    Aug 26, 2022 at 3:13
  • \$\begingroup\$ why does my answer appear higher than yours, lol \$\endgroup\$
    – Joao-3
    Mar 29 at 17:10
1
\$\begingroup\$

Jelly, 12 bytes

⁹Æs;ÆdÆṣƑƲ1#

A full program that will (eventually!) print the result.

Don't Try it online!
The starts the search at 256, if one replaces it with 1 it'll find 12 - try that here.


Faster in 13:

“;Y,’Æf2*×’$P

Try it here.

\$\endgroup\$
1
\$\begingroup\$

Python, 49 46 45 bytes

Did some google calculation.

print(2**126*14448825433*(2**31-1)*(2**61-1))
\$\endgroup\$
1
  • 3
    \$\begingroup\$ There are some more easy golfs, which will lead to basically xnor's solution. \$\endgroup\$
    – Bubbler
    Aug 26, 2022 at 6:22
1
\$\begingroup\$

Thunno, \$ 17 \log_{256}(96) \approx \$ 13.99 bytes

3772545AF2@D1-z*P

Attempt This Online!

Port of Kevin Cruijssen's 05AB1E answer.

3772545AF2@D1-z*P
3772545            # Push 3772545                (there's no integer compression in Thunno)
       AF          # Prime factors of that       ([3, 5, 7, 19, 31, 61])
         2@        # 2 ** each one               ([8, 32, 128, 524288, 2147483648, 2305843009213693952])
           D1-     # Duplicate and subtract one  ([7, 31, 127, 524287, 2147483647, 2305843009213693951])
              z*   # Multiply                    ([56, 992, 16256, 274877382656, 4611686016279904256, 5316911983139663489309385231907684352]) 
                P  # Product of the list         (6086555670238378989670371734243169622657830773351885970528324860512791691264)
\$\endgroup\$
1
\$\begingroup\$

Pyt, 22 17 16 bytes

3772545ǰϼ2⇹^Đ⁻*Π

Try it online!

3772545             push 3, 7, 7, 2, 5, 4, 5
       ǰ            ǰoin elements on stack with no delimiter 
         ϼ          get unique ϼrime factors (casts to integer)
          2⇹^       raise 2 to each power
             Đ⁻     Đuplicate; decrement
               *    element-wise multiplication
                Π   product of list; implicit print
\$\endgroup\$
1
\$\begingroup\$

Jelly, 30 bytes

My first Jelly answer! Hope I'll get better in the future.

2*’
[3,5,7,19,31,61]ç
¢×/æ«126

Attempt This Online!

\$\endgroup\$
1
\$\begingroup\$

J, 23 bytes

echo*/(,<:)2^q:3772545x

Same solution as most answers.

Attempt This Online!

echo*/(,<:)2^q:3772545x
               3772545x  NB. extended precision literal
             q:          NB. prime factors
           2^            NB. raise 2 to each factor
      (,<:)              NB. monadic hook 
        <:               NB. decrement
       ,                 NB. concat with hook input
    */                   NB. product reduce
echo                     NB. print
\$\endgroup\$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.