' aのn乗をmで割った余りを返す Function LargeMod(ByVal a As Long, ByVal n As Long, ByVal m As Long) Dim result As Long result = a Mod m If n >= 2 Then For i = 2 To n result = (result * a) Mod m Next i End If LargeMod = result End Function