Last active
February 21, 2022 12:27
-
-
Save maymax777/2dd128c267715f09c44462b6b31b3b6b 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
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