Bash shell script to find sum of digits
Given a number Num, find the sum of digits of the number.
sum of digits of 444 is : 12
sum of digits of 34 is : 7
1. Divide the number into single digits
2. Find the sum of digits .
[ $Num -gt 0 ]
k=$(( $Num % 10 ))
Num=$(( $Num / 10 ))
s=$(( $s + $k ))
"sum of digits of $g is : $s"
sum of digits of 123 is : 6
Whether you're preparing for your first job interview or aiming to upskill in this ever-evolving tech landscape, GeeksforGeeks Courses
are your key to success. We provide top-quality content at affordable prices, all geared towards accelerating your growth in a time-bound manner. Join the millions we've already empowered, and we're here to do the same for you. Don't miss out - check it out now!