Last active
February 1, 2018 21:45
-
-
Save lhartikk/45ddaff0005f9734d5275a71475c4585 to your computer and use it in GitHub Desktop.
This file contains 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
/* | |
* The "core" logic of the smart contract. | |
* Calculates the equation with provided values for Fermat's last theorem. | |
* Returns the value of a^n + b^n - c^n, n > 2 | |
*/ | |
function solve(int256 a, int256 b, int256 c, int256 n) pure public returns (uint256) { | |
assert(n > 2); | |
uint256 aExp = power(a, n); | |
uint256 bExp = power(b, n); | |
uint256 cExp = power(c, n); | |
uint256 sum = add(aExp, bExp); | |
uint256 difference = sub(sum, cExp); | |
return difference; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment