Skip to content

Instantly share code, notes, and snippets.

@lhartikk
Last active February 1, 2018 21:45
Show Gist options
  • Save lhartikk/45ddaff0005f9734d5275a71475c4585 to your computer and use it in GitHub Desktop.
Save lhartikk/45ddaff0005f9734d5275a71475c4585 to your computer and use it in GitHub Desktop.
/*
* 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