Tuesday, 12 December 2017

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

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


no=1234 '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

Spring Boot : Exception Handler 14