123456789101112131415161718192021222324252627282930313233343536 |
- import java.math.BigInteger;
- /*
- * To change this template, choose Tools | Templates
- * and open the template in the editor.
- */
- /**
- *
- * @author LH
- */
- public class SumSquares
- {
- public static void main(String[] args) throws Exception
- {
- long i1 = InteractiveIO.promptForLong("Zahl bitte");
- long i2 = InteractiveIO.promptForLong("Zweite Zahl bitte");
- long b = 0;
- if(i1>i2)
- {
- b=i1;
- i1=i2;
- i2=b;
-
- }
-
- BigInteger acc = new BigInteger("0");
- //zähler von woanderst :P
- for (; i1 <= i2; i1++)
- {
- acc = acc.add(BigInteger.valueOf(i1).multiply(BigInteger.valueOf(i1)));
- }
- InteractiveIO.write("Ergebnis: "+acc);
- }
- }
|