DulcetAirman icon

1 + (2 + 3 ∗ 4) + (5 + 6 ∗ 7 + 8 ∗ 9 ∗ 10) + ...

DulcetAirman | PRO | 04/25/16 09:55:33 AM UTC | 0 ⭐ | 740 👁️ | Never ⏰ | []
Java |

680 B

|

None

|

0 👍

/

0 👎

package com.example.foo;
 
import java.math.BigInteger;
 
public class SomeClass {
  public static void main(final String[] args) {
    BigInteger x = BigInteger.ZERO;
    BigInteger value = BigInteger.ZERO;
    for (int i = 1; i < 100; i++) {
      BigInteger e = BigInteger.ZERO;
      for (int j = 1; j <= i; j++) {
        BigInteger product = BigInteger.ONE;
        for (long k = 0; k < j; k++)
          product = product.multiply(x = x.add(BigInteger.ONE));
        e = e.add(product);
      }
      value = value.add(e);
      System.out.format("Expression %d : %d%n", i, e);
      // System.out.format("Value : %d%n", value);
    }
    // System.out.println(value);
  }
}

Comments

  •  icon
    01/01/70 12:00:00 AM UTC
    Plain Text |

    0 B

    |

    👍

    /

    👎