Advertisement
silentkiler029

sum of product using modulaar arithmetic

Jun 28th, 2020
138
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 0.26 KB | None | 0 0
  1. #include <stdio.h>
  2. int main()
  3. {
  4.     long long x; // as x <= 10^19
  5.     scanf("%lld", &x);
  6.  
  7.     long long q = x, r, sum = 0;
  8.  
  9.     while(q > 0) {
  10.         r = q % 10;
  11.         sum += r;
  12.         q /= 10;
  13.     }
  14.  
  15.     printf("%lld\n", sum);
  16.  
  17.  
  18.     return 0;
  19. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement