Generation

generate functionSat, 12 Nov 2022

calculate the first 50 fibonacci number's sum

def sumFibonacci(size: Int): Long { var first = 0L var second = 1L var sum = 0L var count = 0 while (count < size) { sum += second val temp = first + second first = second second = temp count += 1 } return sum }

Questions about programming?Chat with your personal AI assistant