Advertisement
DulcetAirman

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

Apr 25th, 2016
253
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 0.68 KB | None | 0 0
  1. package com.example.foo;
  2.  
  3. import java.math.BigInteger;
  4.  
  5. public class SomeClass {
  6.   public static void main(final String[] args) {
  7.     BigInteger x = BigInteger.ZERO;
  8.     BigInteger value = BigInteger.ZERO;
  9.     for (int i = 1; i < 100; i++) {
  10.       BigInteger e = BigInteger.ZERO;
  11.       for (int j = 1; j <= i; j++) {
  12.         BigInteger product = BigInteger.ONE;
  13.         for (long k = 0; k < j; k++)
  14.           product = product.multiply(x = x.add(BigInteger.ONE));
  15.         e = e.add(product);
  16.       }
  17.       value = value.add(e);
  18.       System.out.format("Expression %d : %d%n", i, e);
  19.       // System.out.format("Value : %d%n", value);
  20.     }
  21.     // System.out.println(value);
  22.   }
  23. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement