ぴえろっちが問題をくれた。その1


フィボナッチ数列の項は前の2つの項の和である。最初の2項を 1, 2 とすれば、最初の10項は以下の通りである。


1, 2, 3, 5, 8, 13, 21, 34, 55, 89, ...

数列の項が400万を超えない範囲で、偶数の項の総和を求めよ。

というわけで

Public Module Program

Public Sub Main()

Dim n1 As Long
Dim n2 As Long
Dim limitValue As Long

n1 = 1
n2 = 2
limitValue = 4000000

Dim result As Long

result = Calc(n1, n2, limitValue)

System.Console.WriteLine("Result : " & result)

End Sub


Public Function Calc _
(ByVal n1 As Long, _
ByVal n2 As Long, _
ByVal limitValue As Long) _
As Long

' ここに書く。

End Function

End Module