Hacker News new | past | comments | ask | show | jobs | submit login

the method for 7 works because:

you want to know if 8765 is divisible by 7. take the one's digit and multiply by 21. this gets a number that is divisible by 7 so you can subtract it. this will clear the last digit because we're subtracting this:

last digit * 1 + last digit * 20.

now we have a number that ends in a zero. in this case: 8660

now divide by 10. we can do that because that's dividing by 2 and 5 and that won't affect whether or not 7 can go into the number.

now we have a number to deal with that's at least one digit shorter. repeat until it's obvious if the remaining number divides by 7 or not.




Join us for AI Startup School this June 16-17 in San Francisco!

Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: