Skip to main content
added 83 characters in body
Source Link
Kevin Cruijssen
  • 131.4k
  • 13
  • 144
  • 384

05AB1E, 19 bytes

[¼¾ENnN+N·¾[¼¾ENnN+¾N·¾-1‚ß¾*1‚ß*-,

Port of @alephalpha's Haskell answer.

Outputs indefinitely.

Try it online.Try it online.

Explanation:

[                   # Loop indefinitely:
 ¼                  #  Increase variable `c` by 1 (0 by default)
  ¾E                #  Inner loop `N` in the range [1,`c`]:
    NnN+         #   Push N²+N
 , #  N·¾- Pop and output:
    NnN+¾N·¾-1‚ß*-  #   Push N²+N-c*min(2N-c,1)
    Nn     1‚ß         #   Pop and push min(2N    N+            #      +N
                 -c,1)  #        -
        ¾   ¾*    *   #   Multiply by `c`:    c*
             1‚ß    #           min(2N-c    ,1)*c
             -     #   Subtract: N²+N-min(           2N-c,1)*c
           ¾-    ,   #   Pop and output it with trailing newline        -c

05AB1E, 19 bytes

[¼¾ENnN+N·¾-1‚ß¾*-,

Port of @alephalpha's Haskell answer.

Outputs indefinitely.

Try it online.

Explanation:

[                # Loop indefinitely:
 ¼               #  Increase variable `c` by 1 (0 by default)
  ¾E             #  Inner loop `N` in the range [1,`c`]:
    NnN+         #   Push N²+N
    N·¾-         #   Push 2N-c
        1‚ß      #   Pop and push min(2N-c,1)
           ¾*    #   Multiply by `c`: min(2N-c,1)*c
             -   #   Subtract: N²+N-min(2N-c,1)*c
              ,  #   Pop and output it with trailing newline

05AB1E, 19 bytes

[¼¾ENnN+¾N·¾-1‚ß*-,

Port of @alephalpha's Haskell answer.

Outputs indefinitely.

Try it online.

Explanation:

[                   # Loop indefinitely:
 ¼                  #  Increase variable `c` by 1 (0 by default)
  ¾E                #  Inner loop `N` in the range [1,`c`]:
                  , #   Pop and output:
    NnN+¾N·¾-1‚ß*-  #    N²+N-c*min(2N-c,1)
    Nn              #          N+            #      +N
                 -  #        -
        ¾       *   #         c*
             1‚ß    #           min(    ,1)
                  #               2N
           ¾-       #                 -c
Source Link
Kevin Cruijssen
  • 131.4k
  • 13
  • 144
  • 384

05AB1E, 19 bytes

[¼¾ENnN+N·¾-1‚ß¾*-,

Port of @alephalpha's Haskell answer.

Outputs indefinitely.

Try it online.

Explanation:

[                # Loop indefinitely:
 ¼               #  Increase variable `c` by 1 (0 by default)
  ¾E             #  Inner loop `N` in the range [1,`c`]:
    NnN+         #   Push N²+N
    N·¾-         #   Push 2N-c
        1‚ß      #   Pop and push min(2N-c,1)
           ¾*    #   Multiply by `c`: min(2N-c,1)*c
             -   #   Subtract: N²+N-min(2N-c,1)*c
              ,  #   Pop and output it with trailing newline