codedamn

Find the sum of digits

Created by Kshitij about a year ago

0

No description provided

1 Comment

    0

    // SPDX-License-Identifier: MIT pragma solidity ^0.8.21;

    contract day1 {

    function digitSum(int n) public pure returns(int){
      
      require(n >0 ,"value should be greater than zero");
    
      int sum = 0;
      
      while(n>0){
       sum += n % 10;
       n = n/10;
    
      }
    
      return sum;
    
    }
    

    }

    my code looks fine and even running on remix but when i run test here it fails i dont know why

    @moeez

    Muhammad Moeez Khan

    @moeez

Your comment