[ create a new paste ] login | about

Link: http://codepad.org/EWI1Ja1U    [ raw code | output | fork ]

C++, pasted on Aug 29:
#include <iostream>

int sum_of_digits(int n)
{
  int S = 0;
  while(n)
  {
    S += n % 10;
    n /= 10;
  }

  return S;
}

int main()
{
  int S = 0;
  for(int i = 1; i <= 1000; ++i)
    if(i % 5)
      S += sum_of_digits(i);

  std::cout << S;
}


Output:
1
11200


Create a new paste based on this one


Comments: