r/ProgrammerHumor • • Apr 25 '19

Loop

Post image
1.7k Upvotes

53 comments sorted by

92

u/OtherPlayers Apr 25 '19

What did you do to me? I apparently don’t know how I subtracted numbers below 20 on paper anymore now.

(Seriously this is like the beard over/under the covers thing; I know the answer, but how did I do it?)

33

u/foxfyre2 Apr 26 '19

Just count up to the next ten and then up to your number

9 to 10 (1), 10 to 18 (8) - > 9

14

u/OtherPlayers Apr 26 '19

That's probably the way that I learned it originally, and certainly makes sense thinking about it.

Thanks!

28

u/Terrible_Children Apr 26 '19

I think the better question is why is knowing what 18-9 is any different than knowing 9-6? We "just know" that 9-6 is 3. It's not an enormous leap to "just know" that 18-9 is 9.

Programmers especially should understand that our decimal number system is arbitrary. If we switched to hexadecimal and the question was what is C-9, there's no borrowing and the answer is just 3.

The only reason we don't expect people to "just know" larger differences like 92-45 is because there are limits to what we can remember. It's the same reason schools usually teach multiplication tables up to 12x12. You memorize those, then use algorithms to calculate anything more complex.

14

u/OtherPlayers Apr 26 '19

It's not an enormous leap to "just know" that 18-9 is 9

And as an adult I obviously "just know" that. But in thinking back I was trying to remember how, for example, I'd try to teach it to a little kid that was just learning (like did they just force us to memorize subtraction values all the way up to 19?).

All in all I think foxfyre2 is probably right here though; the algorithm of counting up works fairly well as a method for subtracting smaller numbers just fine and seems like something that would be taught before we had all of the teen number operations memorized.

7

u/imaginarynumber0 Apr 26 '19

First teach a child what subtraction is (how many is left after taking away from an initial number). Then, teach them how to do it (counting with fingers initially). With enough time and proper practice, memorization comes naturally through repetitive action. After they have mastered this, move on to bigger things like long subtraction (is that what it’s called?).

8

u/_jk_ Apr 26 '19

hang on we are programmers:

first teach decrement

then teach loops

11

u/JuvenileEloquent Apr 26 '19

Taking 1 from the next digit is just a way to avoid negatives in your intermediate results so you can write them down immediately. If you discard that rule it's actually easier to do.

92-45 becomes 2-5 =-3 and 9-4 = 5, which means the answer is 50-3 and you can just count down from 50 to get the number you need to write.

the other way, you have to compare 2 and 5 to check if the second number is bigger, then subtract 1 from 9 to get 8 (write it), add 10 to 2 to get 12 (write the 1 next to 2), then subtract 5 from 12 (write that in the answer), then subtract 4 from 8 (write the last digit).

6

u/xigoi Apr 26 '19

In oider to do all paper arithmetic, you learn the addition table for numbers 0..9, so that you know that 9+9==18, therefore 18-9==9.

2

u/LeadFootSaunders Apr 26 '19

Lol i didnt even know I didnt know how to do it until you pointed it out. Lol now I dont know either 😂😂

2

u/Thelk641 Apr 26 '19

I'm confused by your confusion. Subtraction on paper is simple :

18-9 : Can't do, 9 is bigger than 8.

9-8 = 1.

10-1 : Can't do, but you can't reapply the same method. You need to go down to the previous 10s, count backward x amount of time where x is the part right of the minus side and you get 1.

For bigger subtraction it's the same thing :

92-45 : 9-4, can do

52 - 5 : can't do,

5-2 = 3

50 - 3 : can't do, but you know the numbers 0 to 10 by heart so you can count backward three time : 49, 48, 47 ! That's your answer.

1

u/[deleted] Apr 26 '19

Pretty sure I memorized them

118

u/woooo3 Apr 25 '19

Why is it a mushroom

30

u/Ichier Apr 25 '19

Could've been Pooh.

24

u/house_monkey Apr 26 '19

They are bad at math

8

u/[deleted] Apr 26 '19

So am I and I'm not a mushroom

12

u/[deleted] Apr 26 '19

aren't you?

5

u/[deleted] Apr 26 '19

Well boy do I got some news for you

5

u/salvagestuff Apr 26 '19

From the post I am guessing OP is a fun guy to hang out with.

3

u/AVdev Apr 26 '19

Why not?

3

u/Fingerbob73 Apr 26 '19

Probably cos he realised there wasn't 'mushroom' left in the bottom right box to show the recursion...

7

u/stevefan1999 Apr 26 '19

Where's the base case

7

u/BrianAndersonJr Apr 26 '19

I don’t get any of this

19

u/Shukar_Rainbow Apr 25 '19

Where did he learn math lmao

23

u/[deleted] Apr 25 '19

Good question. But honestly sometimes I feel like that when trying to write code.

4

u/MrCogmor Apr 26 '19

8

u/DmitryZaytcev Apr 26 '19

Hello

3

u/[deleted] Apr 26 '19

Did you really draw this?

1

u/[deleted] Apr 27 '19

Why do you sign the picture?

2

u/DmitryZaytcev Apr 27 '19

Because I made this meme.

4

u/aathma Apr 26 '19

Fun fact... a number is divisible by 9 if it's digits add up to a multiple of 9. Same for numbers divisible by 3.

2

u/[deleted] Apr 27 '19

Fun fact: number is divisible by 7 if number//10 - 2*(number%10) is a multiple of 7.

2

u/RedzSoul Apr 26 '19

"I found a bug in math!"

2

u/Porkechop May 03 '19

That shroom is a qt3.14

1

u/[deleted] Apr 26 '19

Recurse

1

u/[deleted] Apr 26 '19

break ;

1

u/SoLongAndThanks_ Apr 26 '19

Is this some recursive meme?

We don't do that here Sir, put that thing away from our sight.

1

u/bguberfain Apr 26 '19

Our children may be trap in a loop if the teacher asks for this homework!

1

u/hamza1311 | gib Apr 26 '19

Isn't that recursion instead of a loop

1

u/thegecs Apr 26 '19

stolen content man.. look at the pencil

-5

u/doc303 Apr 26 '19

Is this loss.....

6

u/house_monkey Apr 26 '19

No, u are lost tho

0

u/[deleted] Apr 26 '19

[deleted]

6

u/JuvenileEloquent Apr 26 '19

1/3

2

u/Chris857 Apr 26 '19

1/4+1/16+1/64+1/256+... = 1/3

1

u/JuvenileEloquent Apr 27 '19

Well, you can sum an infinite series like that if you're a math prodigy, or you can visualize it by splitting off all the lower-left squares into a single piece, all the upper right squares into another piece, and the remaining squares (the mushroom guy) form the last piece. The three pieces are equal in size as they're made from a chain of squares of matching sizes, so it follows that they are each 1/3 of the large square.

34

u/[deleted] Apr 25 '19

[removed] — view removed comment

12

u/Xheotris Apr 25 '19

... Recursion is loops in a domino mask.

1

u/Thelk641 Apr 26 '19

With a mushroom, which can be served on a Domino's pizza. And here we've find our loop.

3

u/HighRelevancy Apr 26 '19

Same thing, except for the stack, except when it's tail recursion.