Guest User

Untitled

a guest
Dec 26th, 2018
155
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.56 KB | None | 0 0
  1. import java.math.BigInteger;
  2. import java.util.Scanner;
  3.  
  4. public class SumBigNumbersInRange {
  5.  
  6. public static void main(String[] args) {
  7. Scanner sc = new Scanner(System.in);
  8.  
  9. BigInteger first = new BigInteger(sc.nextLine());
  10. BigInteger second = new BigInteger(sc.nextLine());
  11.  
  12. BigInteger sum = new BigInteger("0");
  13.  
  14. for (BigInteger i = first; i.compareTo(second) <= 0; i = i.add(BigInteger.valueOf(1))) {
  15. sum = sum.add(BigInteger.valueOf(i));
  16. }
  17. System.out.println(sum);
  18. }
  19. }
Add Comment
Please, Sign In to add comment