Finding last digit of sum from m to n Fibonacci numbers. (0 ≤ 𝑚 ≤ 𝑛 ≤ 10^14)
问题 My code is as follow : m, n = map(int, input().split()) # write function "fibtotal" which takes input x and gives accurate fib(x+2)%10 (as sum till fib(x) == fib(x+2) - 1) # using above function get fibtotal(m-1) and fibtotal(n) # subtract fibtotal(m-1) from fibtotal(n) and do mod 10 gives last digit of sum from m to n # take care of handling large input sizes, 0 ≤ 𝑚 ≤ 𝑛 ≤ 10^14 def fibtotal(x): sum = 1 # if both initial conditions fail then loop starts from 2 x= x % 60 # pisano period of 10