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 Sep 19, 2022
1 parent bd86cfe commit 688680f
Showing 1 changed file with 17 additions and 0 deletions.
17 changes: 17 additions & 0 deletions 07Day-WhileLoop.sol
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
// SPDX-License-Identifier: aIT
pragma solidity >=0.5.0 <0.9.0;

contract day1 {
//Create a function digitSum(int n). Where n>0.
function digitSum(int256 n) public pure returns (int256) {
int256 a;
int256 sum = 0;
while (n > 0) {
a = n % 10;
sum = sum + a;
n = n / 10;
}
//Return the sum of digit for n.
return sum;
}
}

0 comments on commit 688680f

Please sign in to comment.