Skip to main content

You are not logged in. Your edit will be placed in a queue until it is peer reviewed.

We welcome edits that make the post easier to understand and more valuable for readers. Because community members review edits, please try to make the post substantially better than how you found it, for example, by fixing grammar or adding additional resources and hyperlinks.

Required fields*

6
  • \$\begingroup\$ You could use exploded strings (template <char H, char ...T>) in your templates to (theoretically) handle arbitrary-length values. Then it would just be a matter of examining the last 2 characters in each string to determine divisibility by 2 and/or 3. \$\endgroup\$ Commented Nov 9, 2015 at 20:23
  • \$\begingroup\$ @Mego I do not understand you. How it would help me to handle values, which do not fit into 64 bits. Also, You need all digits to find out if the number is divisible by 3. \$\endgroup\$ Commented Nov 9, 2015 at 21:12
  • \$\begingroup\$ Strings can be arbitrarily long (until you run out of memory). And you're right, I messed up my comment. Still, you could compute the digital sum to determine divisibility by 3. \$\endgroup\$ Commented Nov 9, 2015 at 21:27
  • \$\begingroup\$ @Mego Implementing addition of those strings would require much more effort. \$\endgroup\$ Commented Nov 9, 2015 at 22:17
  • 2
    \$\begingroup\$ You could use the gnu dialect and use __uint128_t, maybe. \$\endgroup\$ Commented Nov 12, 2015 at 21:54