How to check for division by 7 for big number in C++?

前端 未结 9 704
傲寒
傲寒 2020-12-17 01:57

I have to check, if given number is divisible by 7, which is usualy done just by doing something like n % 7 == 0, but the problem is, that given number can have

9条回答
  •  情书的邮戳
    2020-12-17 02:43

    Think about how you do division on paper. You look at the first digit or two, and write down the nearest multiple of seven, carry down the remainder, and so on. You can do that on any abritrary length number because you don't have to load the whole number into memory.

提交回复
热议问题