Skip to content

Commit

Permalink
Add files via upload
Browse files Browse the repository at this point in the history
  • Loading branch information
rohitscript authored Oct 1, 2022
1 parent 45c2aa8 commit 42a4a9e
Showing 1 changed file with 16 additions and 0 deletions.
16 changes: 16 additions & 0 deletions 19Day-SumOfSeries.sol
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
// SPDX-License-Identifier: MIT
pragma solidity >=0.5.0 <0.9.0;
//Find the sum of the series 1 + x + x^2+ x^3+ .. + x^n
contract Day1 {
//Create a function expression(x,n)
function expression(uint256 x, uint256 n) public pure returns (uint256) {
uint256 sm = 1;
uint256 m = 1;
for (uint256 i = 1; i <=n; i++) {
m = m * x;
sm = sm + m;

}
return sm;
}
}

0 comments on commit 42a4a9e

Please sign in to comment.