Skip to main content
gamedev.net
🔒 Locked

Consecutive Integer proofs

Started by Gink 5 replies 2.2k views
Original Post
Gink
Gink
How exactly do you prove that the product of n consecutive integers is always divisible by n? (say 2 for example) Here is how far I got Let a/b be 2 consec integers. a b = a + 1 so, a * ( a + 1) = 2n a^2 + a = 2n a(a+1) = 2n What am I missing here?
eleusive
eleusive
Quote:
Original post by Gink
How exactly do you prove that the product of n consecutive integers is always divisible by n? (say 2 for example)

Here is how far I got
Let a/b be 2 consec integers.

a
b = a + 1

so, a * ( a + 1) = 2n
a^2 + a = 2n
a(a+1) = 2n

What am I missing here?


Well, you're on the right track. Since a and a+1 are consecutive, then one of them is even. Any even number times any other number is also even (factorization theorem). The same idea holds for any n. a(a+1)...(a+n-1)=n*k since one of the a-terms is divisible by n, so the product will be too.
"What are you trying to tell me? That I can write an O(N^2) recursive solution for a 2-dimensional knapsack?" "No, programmer. I'm trying to tell you that when you're ready, you won't have to." -Adapted from "The Matrix"
SporadicFire
SporadicFire
a(a + 1) has to be divisible by 2 because either a is divisible by 2 or a+1 is divisible by
2.

Basically we can write any integer as 2*q + r (by definition of integer division), where r=0 or 1. So then a = 2*q + r. Then a+1 = 2*q + r + 1

So then, if r = 0, the a is divisible by 2. If r=1 then a+1 is divisible by 2. In either case a(a+1) is divisible by 2.

To prove this in general for all n you need to use induction. Are you familiar with the concept of induction?
Gink
Gink
So, what exactly would I say to finish this off? Since a or a+1 is divisible by 2, 2n | a*(a+1)?

edit : i'm familiar with induction but i have to prove it for specific numbers
NotAnAnonymousPoster
NotAnAnonymousPoster
Quote:
Original post by Gink
How exactly do you prove that the product of n consecutive integers is always divisible by n? (say 2 for example)

Here is how far I got
Let a/b be 2 consec integers.

a
b = a + 1

so, a * ( a + 1) = 2n
a^2 + a = 2n
a(a+1) = 2n

What am I missing here?
Where did the line

a * (a + 1) = 2n

come from? n is 2 in this case, right, so you're saying that a * (a + 1) = 4?

Anyway, you should think about remainders on division by n instead. You have n consecutive integers, each with a different remainder on division by n. See where you go from there.
"C combines all the power of assembly language with all the ease of use of assembly language"
Gink
Gink
that line is right, when n is the correct value obviously.
Fruny
Fruny
Homework on gamedev.net = don't do it.
"Debugging is twice as hard as writing the code in the first place. Therefore, if you write the code as cleverly as possible, you are, by definition, not smart enough to debug it." — Brian W. Kernighan

Topic Locked

This topic has been locked by a moderator. New replies are not allowed.

Sign in to reply to this topic.