Skip to main content
added 166 characters in body
Source Link

Jelly, 99 8 bytes

Żp`×ÄSƊ€iŻp`ḋÄ$€i

Try it online! or try the test suite (some larger inputs excluded for time reasons)Try it online!

Returns a non-zero integer for Loeschian numbers and \$0\$ for non-Loeschian numbers

-1 byte thanks to Sisyphus

May be a little cheeky to post, as the only reason this is shorter than Leaky's and Dennis’ Jelly answer is due to newer features, but it's different enough from the existing Jelly answers.

How it works

Żp`×ÄSƊ€iŻp`ḋÄ$€i - Main link. Takes k on the left
Ż         - Yield [0, 1, 2, ..., k]
  `       - Use this as both left and right argument for:
 p        -   Cartesian power
      Ɗ€$€  - Over each pair, [i, j], run the previous threetwo commands:
    Ä     -   Cumulative sum; [i, i+j]
   ×      -   Multiply; [i×i, j×(i+j)]
     S  Dot product -with [i, j]; Sum;Yields i×i+j×(i+j) = i×i + i×j + j×j
            This yields all Loeschian numbers below 3k²
        i - Index of k in this list, or 0 if not found

Jelly, 9 bytes

Żp`×ÄSƊ€i

Try it online! or try the test suite (some larger inputs excluded for time reasons)

Returns a non-zero integer for Loeschian numbers and \$0\$ for non-Loeschian numbers

May be a little cheeky to post, as the only reason this is shorter than Leaky's Jelly answer is due to newer features, but it's different enough from the existing Jelly answers.

How it works

Żp`×ÄSƊ€i - Main link. Takes k on the left
Ż         - Yield [0, 1, 2, ..., k]
  `       - Use this as both left and right argument for:
 p        -   Cartesian power
      Ɗ€  - Over each pair, [i, j], run the previous three commands:
    Ä     -   Cumulative sum; [i, i+j]
   ×      -   Multiply; [i×i, j×(i+j)]
     S    -   Sum; i×i+j×(i+j) = i×i + i×j + j×j
            This yields all Loeschian numbers below 3k²
        i - Index of k in this list, or 0 if not found

Jelly, 9 8 bytes

Żp`ḋÄ$€i

Try it online!

Returns a non-zero integer for Loeschian numbers and \$0\$ for non-Loeschian numbers

-1 byte thanks to Sisyphus

May be a little cheeky to post, as the only reason this is shorter than Leaky's and Dennis’ Jelly answer is due to newer features, but it's different enough from the existing Jelly answers.

How it works

Żp`ḋÄ$€i - Main link. Takes k on the left
Ż        - Yield [0, 1, 2, ..., k]
  `      - Use this as both left and right argument for:
 p       -   Cartesian power
     $€  - Over each pair, [i, j], run the previous two commands:
    Ä    -   Cumulative sum; [i, i+j]
        -   Dot product with [i, j]; Yields i×i+j×(i+j) = i×i + i×j + j×j
           This yields all Loeschian numbers below 3k²
       i - Index of k in this list, or 0 if not found
Source Link

Jelly, 9 bytes

Żp`×ÄSƊ€i

Try it online! or try the test suite (some larger inputs excluded for time reasons)

Returns a non-zero integer for Loeschian numbers and \$0\$ for non-Loeschian numbers

May be a little cheeky to post, as the only reason this is shorter than Leaky's Jelly answer is due to newer features, but it's different enough from the existing Jelly answers.

How it works

Żp`×ÄSƊ€i - Main link. Takes k on the left
Ż         - Yield [0, 1, 2, ..., k]
  `       - Use this as both left and right argument for:
 p        -   Cartesian power
      Ɗ€  - Over each pair, [i, j], run the previous three commands:
    Ä     -   Cumulative sum; [i, i+j]
   ×      -   Multiply; [i×i, j×(i+j)]
     S    -   Sum; i×i+j×(i+j) = i×i + i×j + j×j
            This yields all Loeschian numbers below 3k²
        i - Index of k in this list, or 0 if not found