Advertisement
Guest User

Even Digit Sum

a guest
Feb 27th, 2015
220
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.69 KB | None | 0 0
  1. #include <iostream>
  2. #include <stdio.h>
  3. #include <cstdlib>
  4. unsigned short int sum, modulo, base;
  5. unsigned long long int n;
  6. bool current;
  7. bool baseConvertDigitMod(unsigned long long int number, unsigned short int baseTo)
  8. {
  9.     sum = 0;
  10.     while (number > 0)
  11.     {
  12.         modulo = number%baseTo;
  13.         sum += modulo;
  14.         number /= baseTo;
  15.     }
  16.     if ((sum & 1)== 0)
  17.         return false;
  18.     else return true;
  19. }
  20. int main()
  21. {
  22.     n = 64;
  23.     for (n = 60000000000; n < 80000000000; n += 2)
  24.     {
  25.         current = true;
  26.         for (base = 2; base < 100; base+=2)
  27.         {
  28.             if (baseConvertDigitMod(n, base))
  29.                 break;
  30.         }
  31.         if (base > 50)
  32.         {
  33.             printf("%15llu %hu \n", n,base-1);
  34.         }
  35.     }
  36.     printf("%s", "Done!");
  37.     return 0;
  38. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement