Page 2 of 2

11332 - Summing Digits

Posted: Sat Aug 16, 2008 10:44 pm
by rajib_sust
you do not need any calculation it is just like this. this is from number theory

Code: Select all

		temp = number % 9;
		if( temp == 0 ) temp = 9;

Rajib, sust

Re: 11332 - Summing Digits

Posted: Thu Mar 31, 2011 10:22 pm
by mahi_seu.bd
summing digit=1+(n-1)%9;
The process continues until a single-digit number is reached.
:P
It's formula knows as Digital root...

Re: 11332 - Summing Digits

Posted: Tue Nov 15, 2011 7:53 am
by kc655039
Does anyone know how to make it take 0.000?

It still took 0.004 with the code below.

Code: Select all

#include <stdio.h>

int
main(int argc, char** argv) {
  int g;
  scanf("%d", &g);
  while (g) {
    g %= 9;
    if (g == 0) {
      g = 9;
    }
    printf("%d\n", g);
    scanf("%d", &g);
  }

  return 0;
}