Skip to main content
deleted 28 characters in body
Source Link
Neil
  • 177.2k
  • 12
  • 74
  • 281

Charcoal, 12 10 bytes

IΣEN×ιX⊕ι²

Try it online! Link is to verbose version of code. Explanation: \$ ( \sum x )^2 = \sum x^3 \$\$ ( \sum_1^n x )^2 = \sum_1^n x^3 \$ so \$ ( \sum_1^n x )^2 - \sum_1^n x^2 = \sum_1^n (x^3 - x^2) = \sum_1^n (x - 1)x^2 = \sum_0^{n-1} x(x + 1)^2 \$.

   N        Input number
  E         Map over implicit range i.e. 0 .. n - 1
        ι   Current value
       ⊕    Incremented
         ²  Literal 2
      X     Power
     ι      Current value
    ×       Multiply
 Σ          Sum
I           Cast to string
            Implicitly print

Charcoal, 12 10 bytes

IΣEN×ιX⊕ι²

Try it online! Link is to verbose version of code. Explanation: \$ ( \sum x )^2 = \sum x^3 \$

   N        Input number
  E         Map over implicit range i.e. 0 .. n - 1
        ι   Current value
       ⊕    Incremented
         ²  Literal 2
      X     Power
     ι      Current value
    ×       Multiply
 Σ          Sum
I           Cast to string
            Implicitly print

Charcoal, 12 10 bytes

IΣEN×ιX⊕ι²

Try it online! Link is to verbose version of code. Explanation: \$ ( \sum_1^n x )^2 = \sum_1^n x^3 \$ so \$ ( \sum_1^n x )^2 - \sum_1^n x^2 = \sum_1^n (x^3 - x^2) = \sum_1^n (x - 1)x^2 = \sum_0^{n-1} x(x + 1)^2 \$.

   N        Input number
  E         Map over implicit range i.e. 0 .. n - 1
        ι   Current value
       ⊕    Incremented
         ²  Literal 2
      X     Power
     ι      Current value
    ×       Multiply
 Σ          Sum
I           Cast to string
            Implicitly print
deleted 28 characters in body
Source Link
Neil
  • 177.2k
  • 12
  • 74
  • 281

Charcoal, 1212 10 bytes

IΣE⊕N⁻Xι³Xι²IΣEN×ιX⊕ι²

Try it online! Link is to verbose version of code. Explanation: \$ ( \sum x )^2 = \sum x^3 \$

            Input number
  Incremented
               Map over implicit range i.e. 0 .. n
  - 1
    ι  ι  ι   Current value
        ³       Literal 3Incremented
           ²    Literal 2
            Power
     ι      Current value
   Subtract
 Σ×       Multiply
 Σ      Sum
I    Sum
I           Cast to string
                Implicitly print

Charcoal, 12 bytes

IΣE⊕N⁻Xι³Xι²

Try it online! Link is to verbose version of code. Explanation: \$ ( \sum x )^2 = \sum x^3 \$

            Input number
  Incremented
               Map over implicit range i.e. 0 .. n
       ι  ι     Current value
        ³       Literal 3
           ²    Literal 2
            Power
               Subtract
 Σ              Sum
I               Cast to string
                Implicitly print

Charcoal, 12 10 bytes

IΣEN×ιX⊕ι²

Try it online! Link is to verbose version of code. Explanation: \$ ( \sum x )^2 = \sum x^3 \$

   N        Input number
  E         Map over implicit range i.e. 0 .. n - 1
        ι   Current value
           Incremented
         ²  Literal 2
      X     Power
     ι      Current value
    ×       Multiply
 Σ          Sum
I           Cast to string
            Implicitly print
Source Link
Neil
  • 177.2k
  • 12
  • 74
  • 281

Charcoal, 12 bytes

IΣE⊕N⁻Xι³Xι²

Try it online! Link is to verbose version of code. Explanation: \$ ( \sum x )^2 = \sum x^3 \$

    N           Input number
   ⊕            Incremented
  E             Map over implicit range i.e. 0 .. n
       ι  ι     Current value
        ³       Literal 3
           ²    Literal 2
      X  X      Power
     ⁻          Subtract
 Σ              Sum
I               Cast to string
                Implicitly print