title: C program that outputs if a number is divisble by 3 or not
body: <p>I am new to programming, and I have to make an assignment in C. I have to make a program that reads an integer n and outputs if it is divisible by 3. Unfortunately I am not allowed to use the % operator to check this. &quot;A positive integer is divisible by 3 if and only if the sum of all its digits is divisible by 3.&quot; So the program must add the digits of n, and if this is larger then 9, I have to add the digits of this number etc, until the sum of the digits is equal to or less then 9. Because then I am allowed to say whether n is divisible by 3 or not. I also have to print the number of the lose digits each time. For example: input:9999-----output:9999 -&gt; 36 -&gt; 9. YES.
  I made a loop:</p>
  <pre><code>    while(n&gt;9){
      lastDigit = n%10;
      sumDigits += lastDigit;
      n = (n-lastDigit)/10;
   }
      sumDigits = sumDigits + n; /*this is the sum of the digits*/
  </code></pre>
  <p>Now if this is larger then 9, I have to enter this number in the loop again, but I don't know how to do this. I made 3 other loops with if else statements, but that way my program is way to long. How can I make my program shorter? Because some numbers have to go through the loop multiple times.</p>
  <p>Thanks.</p>
  <p>Niek</p>