Answers for "using recursion to sum numbers js"

3

how to sum digits of a number in python

number = 123 # the number you want summed up
sum_of_digits = 0 
for digit in str(number):
  sum_of_digits += int(digit)
  
print(sum_of_digits) # printing the final sum of number
Posted by: Guest on April-25-2020
3

sum of digits in c#

int num = 123;
int sum = 0;
while(num > 0)
{
  sum += number % 10;
  num /= 10;
}
Console.WriteLine(sum); // output: 6
Posted by: Guest on April-26-2020

Code answers related to "using recursion to sum numbers js"

Python Answers by Framework

Browse Popular Code Answers by Language