Answers for "Find the number of 6 digits numbers whose sum is 10, using the digits 1, 2, 3 only."

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 "Find the number of 6 digits numbers whose sum is 10, using the digits 1, 2, 3 only."

Python Answers by Framework

Browse Popular Code Answers by Language