Consecutive sum

Report a typo

Implement the method consecutiveSum that takes two ints: start and end. The method must return a Callable<Integer>, which counts the sum of all numbers from start to end (inclusive).

Sample input 1:

1 100

Sample output 1:

5050

Sample input 2:

70 7000

Sample output 2:

24501085

Sample Input 1:

1 100

Sample Output 1:

5050
Write a program in Java 17
import java.util.Scanner;
import java.util.concurrent.*;

class Numbers {

public static Callable<Integer> consecutiveSum(int start, int end) {
// write your code here
return null;
}

// Don't change the code below
public static void main(String[] args) {
Scanner scanner = new Scanner(System.in);
int start = scanner.nextInt();
int end = scanner.nextInt();

ExecutorService executorService = Executors.newSingleThreadExecutor();
Future<Integer> future = executorService.submit(consecutiveSum(start, end));

int result = 0;
try {
result = future.get();
} catch (InterruptedException | ExecutionException e) {
e.printStackTrace();
}

executorService.shutdown();
System.out.println(result);
}
}
___

Create a free account to access the full topic