Skip to content

Instantly share code, notes, and snippets.

@maymax777
Last active February 21, 2022 12:27
Show Gist options
  • Save maymax777/2dd128c267715f09c44462b6b31b3b6b to your computer and use it in GitHub Desktop.
Save maymax777/2dd128c267715f09c44462b6b31b3b6b to your computer and use it in GitHub Desktop.
pragma solidity ^0.4.19;
contract Problem {
function rowSumOddNumbers(int n) public pure returns (int) {
int end = (1 + n ) * n - 1;
int start = end - 2 * (n - 1);
int sum = (start + end) * n / 2;
return sum;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment