Answers for ". What is the sum of the digits of integer x, where x = 8^10 × 5^26?"

0

sum the digits of an integer

def getSum(n)
  n.digits.sum
end

print "Sum of digits = ", getSum(555);
Posted by: Guest on May-27-2021
-2

sum the digits of an integer

#include <stdio.h>
 
int getSum(unsigned long long n) {
    int sum = 0;
    for (; n; n /= 10)
    	sum += n % 10;
    return sum;
}

int main(){
	printf("Sum of digits = %d\n", getSum(555));
}
Posted by: Guest on May-27-2021

Code answers related to ". What is the sum of the digits of integer x, where x = 8^10 × 5^26?"

Python Answers by Framework

Browse Popular Code Answers by Language