d2jsp
Log InRegister
d2jsp Forums > Off-Topic > General Chat > Homework Help > Math N Plus 1
Add Reply New Topic New Poll
Member
Posts: 27,518
Joined: May 10 2009
Gold: 13,891.00
Apr 28 2017 10:56pm
Need help please.

1) What is the answer?
2) How did you do it?

Q: How many sequences does it take to get from 20 to 30,000 if:
Start at 20
Each sequence is previous +1 (so 20 + (20+1) + (20+2) + (20+3) = 86 for example which was 4 sequences)


Thanks
Member
Posts: 35,291
Joined: Aug 17 2004
Gold: 12,730.67
Apr 29 2017 01:56am
Quote (Stealth @ Apr 28 2017 08:56pm)
Need help please.

1) What is the answer?
2) How did you do it?

Q: How many sequences does it take to get from 20 to 30,000 if:
Start at 20
Each sequence is previous +1 (so 20 + (20+1) + (20+2) + (20+3) = 86 for example which was 4 sequences)


Thanks


You're looking for the sum of 20+i where i goes from 0 to n. That means you have n+1 terms a.k.a the number of sequences.

So, you have something that looks like 20+(20+1)+...+(20+n) and that must equal 30,000. Notice that the number 20 appears n+1 times. Therefore, you can rewrite this as 20(n+1)+the rest. Note that "the rest" is just the sum of 1 to n.

What's the sum from 1 to n? It's n(n+1)/2 (a.k.a. Gauss' Formula).

So now you have 20(n+1)+n(n+1)/2 = 30000.
20n+20+(n^2)/2 +n/2 = 30000
40n+40+n^2+n = 60K

n^2 +41n -59960

Use the quadratic formula to get your answer which is a little over 225 and since we're dealing with integers, the answer is 226 terms.
Member
Posts: 16,695
Joined: Oct 14 2008
Gold: 0.00
Apr 29 2017 09:54am
Quote (thundercock @ Apr 29 2017 03:56am)
You're looking for the sum of 20+i where i goes from 0 to n. That means you have n+1 terms a.k.a the number of sequences.

So, you have something that looks like 20+(20+1)+...+(20+n) and that must equal 30,000. Notice that the number 20 appears n+1 times. Therefore, you can rewrite this as 20(n+1)+the rest. Note that "the rest" is just the sum of 1 to n.

What's the sum from 1 to n? It's n(n+1)/2 (a.k.a. Gauss' Formula).

So now you have 20(n+1)+n(n+1)/2 = 30000.
20n+20+(n^2)/2 +n/2 = 30000
40n+40+n^2+n = 60K

n^2 +41n -59960

Use the quadratic formula to get your answer which is a little over 225 and since we're dealing with integers, the answer is 226 terms.


I think your setup might be off. I believe It's 20n + (n-1)(n)/2 = 3000 or alternatively you could add 1 to your solution
Member
Posts: 16,209
Joined: Apr 13 2009
Gold: 10.00
May 1 2017 08:42am
int num = 20; // base number
int i = 0; // index starting at 0, increased to 1 before the first calculation
while (num <= 30000) { // stop the loop if num > 30000
i++; // increase the index
num = num + (20 + i); // 20 + 21 + 22 + ... + n + n+1
}
System.out.println("Number: " + num + " | Index: " + i); // output results
Number: 30191 | Index: 226

"//" denotes comments explaining the purpose of each line
index 226 is necessary because index 225 = 30191 - 226 = 29965 which is obviously < 30000

this however assumes that 20 = sequence(0) as a base start, and sequence(1) is 20 + 21 = 41, which is fairly standard.
but you say: Each sequence is previous +1 (so 20 + (20+1) + (20+2) + (20+3) = 86 for example which was 4 sequences)

if your teacher follows this and teaches you this notion, then you simply add 1 to the result to bring it up to index 227
sequence(1) = 20, sequence(2) = 41, sequence(3) = 63, sequence(4) = 86
when i see this, i assume sequence(0) = 19, thus you are starting at 19 rather than 20.
but if your teacher is teaching you otherwise, you basically just follow their rules or get points deducted even if they are wrong.

if you believe that you may be wrong, and that this rather counts as 3 sequences, then follow with the calculated index 226
sequence(0) = 20, sequence(1) = 41, sequence(2) = 63, sequence(3) = 86


Quote (sentries @ Apr 30 2017 01:54am)
I think your setup might be off. I believe It's 20n + (n-1)(n)/2 = 3000 or alternatively you could add 1 to your solution


his answer matches mine, and we're assuming he followed his formula to achieve his answer.
if you're able to get the same answer using your formula, that only proves that there is more than one formula to solve the same question. which isn't unusual.

This post was edited by Kokua on May 1 2017 08:52am
Member
Posts: 27,518
Joined: May 10 2009
Gold: 13,891.00
May 1 2017 09:24am
This has been a great help everyone :)
Thank you. You did answer my question
Member
Posts: 16,209
Joined: Apr 13 2009
Gold: 10.00
May 1 2017 10:14am
Quote (Kokua @ May 2 2017 12:42am)
index 226 is necessary because index 225 = 30191 - 226 = 29965 which is obviously < 30000


this part is actually slightly incorrect, but still a true statement
it's index 226, but with 20 added to that index, thus it would be
index 225 = 30191 - (20 + 226) = 29945
and the rest of the statement is still the same

Quote (Stealth @ May 2 2017 01:24am)
This has been a great help everyone :)
Thank you. You did answer my question


i'm curious if your teacher expected 226 or 227 for the answer, or accepted either if labeled in such ways that it made sense :lol:
Go Back To Homework Help Topic List
Add Reply New Topic New Poll