Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <stdio.h>
- int f(int n)
- {
- int sum=0;
- while (n)
- {
- int digit =n % 10;
- sum+=digit;
- n/=10;
- }
- return sum;
- }
- int main()
- {
- for (int i=1; i<10000; i++)
- printf("%i ", f(i));
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment