Created
March 12, 2013 15:53
-
-
Save jbranchaud/5144062 to your computer and use it in GitHub Desktop.
Verifying Fibonacci with Microsoft's Dafny
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function method Fibonacci(n: int): int | |
requires n >= 0; | |
decreases n; | |
{ | |
if n < 2 then n else Fibonacci(n-2) + Fibonacci(n-1) | |
} | |
method Testing() { | |
assert 0 == Fibonacci(0); | |
assert 1 == Fibonacci(1); | |
assert 1 == Fibonacci(2); | |
assert 2 == Fibonacci(3); | |
assert 3 == Fibonacci(4); | |
assert 5 == Fibonacci(5); | |
assert 8 == Fibonacci(6); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment