Live data from Hacker News

Techniques for Factoring Numbers in Your Head

exupero.org

11–20 of 38 posts

Re: Techniques for Factoring Numbers in Your Head

#11
post #9

Long division is hard to do in your head, but to determine if a number is a factor, there's a technique in between long division and memorizing a graph walk that is probably easier to do mentally that either one (since you don't have to memorize a graph for each divisor). With "modulo division" you can calculate a running remainder in your head while consuming one digit at a time of the dividend, from left to right.…

There's no graph-memorising in the linked method. Modulo division looks pretty good though.

Re: Techniques for Factoring Numbers in Your Head

#12
> Given the number n and prime p, calculate a and b. a is p subtracted from the nearest multiple of 10. b is that same multiple of 10 divided by 10.

This part threw me for a bit until I realized that numbers that end in 5 can't be prime, other than 5 itself. And I don't really need a rule to test divisibility by 5.

Re: Techniques for Factoring Numbers in Your Head

#13
post #9

Long division is hard to do in your head, but to determine if a number is a factor, there's a technique in between long division and memorizing a graph walk that is probably easier to do mentally that either one (since you don't have to memorize a graph for each divisor). With "modulo division" you can calculate a running remainder in your head while consuming one digit at a time of the dividend, from left to right.…

The "square root by subtraction" seems like the same algorithm that can be "implemented" by hand relatively easily on early mechanical calculators:

https://www.youtube.com/watch?v=K_c9-Y1ouww

Re: Techniques for Factoring Numbers in Your Head

#14
post #9

Long division is hard to do in your head, but to determine if a number is a factor, there's a technique in between long division and memorizing a graph walk that is probably easier to do mentally that either one (since you don't have to memorize a graph for each divisor). With "modulo division" you can calculate a running remainder in your head while consuming one digit at a time of the dividend, from left to right.…

The "square root by subtraction" seems like the same algorithm that can be "implemented" by hand relatively easily on early mechanical calculators: https://www.youtube.com/watch?v=K_c9-Y1ouww

What is this thing?? I totally have no use for it, and still I want one.

I'm very not sure what it's doing, but it looks like a different algorithm to me; there are a surprising number of square root techniques. https://en.m.wikipedia.org/wiki/Methods_of_computing_square_...

Re: Techniques for Factoring Numbers in Your Head

#15
post #14

Earlier quoted context omitted.

The "square root by subtraction" seems like the same algorithm that can be "implemented" by hand relatively easily on early mechanical calculators: https://www.youtube.com/watch?v=K_c9-Y1ouww

What is this thing?? I totally have no use for it, and still I want one. I'm very not sure what it's doing, but it looks like a different algorithm to me; there are a surprising number of square root techniques. https://en.m.wikipedia.org/wiki/Methods_of_computing_square_...

It's a Curta: https://en.wikipedia.org/wiki/Curta

Re: Techniques for Factoring Numbers in Your Head

#16
post #14

Earlier quoted context omitted.

The "square root by subtraction" seems like the same algorithm that can be "implemented" by hand relatively easily on early mechanical calculators: https://www.youtube.com/watch?v=K_c9-Y1ouww

What is this thing?? I totally have no use for it, and still I want one. I'm very not sure what it's doing, but it looks like a different algorithm to me; there are a surprising number of square root techniques. https://en.m.wikipedia.org/wiki/Methods_of_computing_square_...

ReCurta: Our goal is to build the first Curta calculator since 1972 | https://news.ycombinator.com/item?id=16035091

Re: Techniques for Factoring Numbers in Your Head

#17
post #8

It looks like step 4 should say something like (edited): If b evenly divides a × r_i , where r_i is the current value, divide by b. If not, add or subtract p until the result is evenly divisible by b, then divide by b. And step 6 should loop back to step 4 and define r_i to be the "result". This method is very interesting and systematic, but it seems pretty complicated compared to ad hoc reasoning. E.g. 34 is a multi…

Yeah I was thinking one of the steps after the first one should probably mention a. :P The example clarified, but it looks like the steps might be both simpler and more clear by writing the formulas for each step.

Re: Techniques for Factoring Numbers in Your Head

#18
I factor numbers up to 3 or 4000 as my form of "counting sheep" when I want to relax and sleep. It's not hard. Obviously, you only need to check primes up to the square root of the number in question. 2, 3, 5 and 11 are easy to check. Beyond that, my main trick is to quickly reduce a divisibility check to a check on a smaller number. For example, if I want to know whether 2747 is divisible by 7, that's true if and only if 2040 is, which is divisible by 7 iff 204 is, which is divisible by 7 if 102 is, which is divisible by 7 iff 51 is, and it isn't. Alternatively, 2747 is divisible by 7 iff 2800-2747 = 53 is, which it isn't.

To check 13, I might subtract off 2600 to get 147, then also 130 to get 17. Or I might have started by adding 13 to get 2760 and hence 276, then subtracted 260 or 26.

To check 17 subtract it once to get 2730 and hence 273. Then add it to get 290 and hence 29.

To check 19 subtract 1900 to get 847, then 38 to get 805. Divide by 5 to get 161, add 19, and we've pretty much gotten to "no".

For 23 add it to 2747 to get 2770 and 277, then substract 230 to get 47.

2900 - 2747 = 153, which can only be divisible by 29 if it equals 29 x 7 (because else the last digit wouldn't be 3), which it doesn't.

Similarly, 31 doesn't divide 353.

2747 - 37 = 2710, and now there's a special trick, because 37 divides 111. 271 - 111 = 136. 136 - 37 = 99, which 37 obviously doesn't divide.

At 41 I'll just do a size check. 41 x 57 is too small, and 57 isn't prime anyway. 41 * 77 also couldn't work. So it's 41 x 67 or bust. That's 2400 + 280 + 60 + 7 ... and we have a winner! 2747 = 41 x 67. Checking the multiplication, (40+1) x (70-3) = 2800 + 70 - 120 - 3, which indeed works out to 2747.

Re: Techniques for Factoring Numbers in Your Head

#19

I factor numbers up to 3 or 4000 as my form of "counting sheep" when I want to relax and sleep. It's not hard. Obviously, you only need to check primes up to the square root of the number in question. 2, 3, 5 and 11 are easy to check. Beyond that, my main trick is to quickly reduce a divisibility check to a check on a smaller number. For example, if I want to know whether 2747 is divisible by 7, that's true if and on…

You should put spaces around your asterisks so they don't make italics (or use ×).
Post reply on HN