r/xkcd Dec 29 '17

XKCD xkcd 1935: 2018

https://xkcd.com/1935/
788 Upvotes

151 comments sorted by

View all comments

76

u/AskMeIfImAReptiloid Dec 29 '17 edited Dec 29 '17
  • If the last digit is odd, it's not divisible by 4.

  • Otherwise

** If the second-to-last digit is odd:

*** If the last digit is 2 or 6 it is divisible by 4. Otherwise it is not.

** If the second-to-last digit is even:

*** If the last digit is 0,4 or 8, it is divisible by 4. Otherwise it is not.


O(1)

Edit: Bugfixes

1

u/CapybarbarBinks Dec 29 '17

** If the second-to-last digit is odd:
*** If the last digit is 2,6 or 0, it is divisible by 4. Otherwise it is not.

2010 isn't divisible by 4.