Question
This is an assignment for a Coursera course.

This is the algorithm I wrote.
import java.util.*;
public class FibonacciPartialSum {
private static long getFibonacciPartialSumNaive(long from, long to) {
if (to <= 1)
return to;
long prev = 0;
long cur = 1;
long sum;
if(from == 1) {
sum = 1;
}
else {
sum = 0;
}
for (long i = 2; i <= to; i++) {
long temp_prev = prev;
prev = cur;
cur = (cur + temp_prev) % 10;
if (i >= from) {
sum = (sum + cur) % 10;
}
}
return sum;
}
public static void main(String[] args) {
Scanner scanner = new Scanner(System.in);
long from = scanner.nextLong();
long to = scanner.nextLong();
//long from = 1234;
//long to = 12345;
System.out.println(getFibonacciPartialSumNaive(from, to));
scanner.close();
}
}
When I submit it to auto grader in Coursera it states that I failed the time test.
Failed case #8/12: time limit exceeded Input: 1 10000000000 Your output: stderr: (Time used: 3.03/1.50, memory used: 26427392/536870912.)
This is an assignment- and a trivial one: what do you know/can you find out about F₁+…+Fₙ? \$\endgroup\$