Sunday, February 10, 2013

Find the sum of the digits till the sum reaches to a single digit


no=54563 'You can give any number you want

While no>0
    modValue=no mod 10
    result=result+modValue
    no=int(no/10)
    If no=0 and result >9 Then
        no=result
        result=0
    End If
Wend
print result

No comments:

Post a Comment