1
0

SumSquares.java 824 B

123456789101112131415161718192021222324252627282930313233343536
  1. import java.math.BigInteger;
  2. /*
  3. * To change this template, choose Tools | Templates
  4. * and open the template in the editor.
  5. */
  6. /**
  7. *
  8. * @author LH
  9. */
  10. public class SumSquares
  11. {
  12. public static void main(String[] args) throws Exception
  13. {
  14. long i1 = InteractiveIO.promptForLong("Zahl bitte");
  15. long i2 = InteractiveIO.promptForLong("Zweite Zahl bitte");
  16. long b = 0;
  17. if(i1>i2)
  18. {
  19. b=i1;
  20. i1=i2;
  21. i2=b;
  22. }
  23. BigInteger acc = new BigInteger("0");
  24. //zähler von woanderst :P
  25. for (; i1 <= i2; i1++)
  26. {
  27. acc = acc.add(BigInteger.valueOf(i1).multiply(BigInteger.valueOf(i1)));
  28. }
  29. InteractiveIO.write("Ergebnis: "+acc);
  30. }
  31. }