PDA

View Full Version : For all you math puzzle nuts...


TBag
10-04-2005, 04:48 PM
I came across this problem while doing my Calc hw today. Took me awhile to get it, I thought it was a pretty neat problem.

Find a formula for the nth term of this sequence.
0, 1, 1, 2, 2, 3, 3, 4, ... (each positive integer repeated).

The whole time I was doing this I was thinking about how much easier it would be to just write a C code for it, damn calculus and it's lack of ability to round down to the nearest factor of 2. Enjoy.

Edit - fixed sequence typo, and edited to add no using mod or anything such as that. Only standard math terms, ie. + , - , x , divide, and powers.

Edited again to say that you can only use one function that will apply to your whole sequence, no dividing odds and evens between two seperate functions.

Homer
10-04-2005, 04:55 PM
[ QUOTE ]
I came across this problem while doing my Calc hw today. Took me awhile to get it, I thought it was a pretty neat problem.

Find a formula for the nth term of this sequence.
0, 1, 1, 2, 3, 3, 4, ... (each positive integer repeated).

The whole time I was doing this I was thinking about how much easier it would be to just write a C code for it, damn calculus and it's lack of ability to round down to the nearest factor of 2. Enjoy.

[/ QUOTE ]

I assume it should be 0, 1, 1, 2, 2, 3, 3...

(n - n mod 2)/2

Homer
10-04-2005, 05:01 PM
[ QUOTE ]
I came across this problem while doing my Calc hw today. Took me awhile to get it, I thought it was a pretty neat problem.

Find a formula for the nth term of this sequence.
0, 1, 1, 2, 2, 3, 3, 4, ... (each positive integer repeated).

The whole time I was doing this I was thinking about how much easier it would be to just write a C code for it, damn calculus and it's lack of ability to round down to the nearest factor of 2. Enjoy.

Edit - fixed sequence typo, and edited to add no using mod or anything such as that. Only standard math terms, ie. + , - , x , divide, and powers.

[/ QUOTE ]

Now you say that. Bastard! /images/graemlins/smile.gif

Isn't mod a standard math term, though.

Okay, I'll try again.

TBag
10-04-2005, 05:02 PM
Haha, when I said I was thinking about how easy it would be to write a C code for it instead of doing standard math procedures, I thought that would've gotten the point across /images/graemlins/grin.gif

BruceZ
10-04-2005, 05:10 PM
[ QUOTE ]
I came across this problem while doing my Calc hw today. Took me awhile to get it, I thought it was a pretty neat problem.

Find a formula for the nth term of this sequence.
0, 1, 1, 2, 2, 3, 3, 4, ... (each positive integer repeated).

The whole time I was doing this I was thinking about how much easier it would be to just write a C code for it, damn calculus and it's lack of ability to round down to the nearest factor of 2. Enjoy.

Edit - fixed sequence typo, and edited to add no using mod or anything such as that. Only standard math terms, ie. + , - , x , divide, and powers.

[/ QUOTE ]

f(n) = n/2 for n even
f(n) = (n+1)/2 for n odd

cookie
10-04-2005, 05:13 PM
[ QUOTE ]
[ QUOTE ]
I came across this problem while doing my Calc hw today. Took me awhile to get it, I thought it was a pretty neat problem.

Find a formula for the nth term of this sequence.
0, 1, 1, 2, 2, 3, 3, 4, ... (each positive integer repeated).

The whole time I was doing this I was thinking about how much easier it would be to just write a C code for it, damn calculus and it's lack of ability to round down to the nearest factor of 2. Enjoy.

Edit - fixed sequence typo, and edited to add no using mod or anything such as that. Only standard math terms, ie. + , - , x , divide, and powers.

[/ QUOTE ]

f(n) = n/2 for n even
f(n) = (n+1)/2 for n odd

[/ QUOTE ]
f(n) = (n+1)/2 for n odd should be (n-1)/2, right?

TBag
10-04-2005, 05:14 PM
Only one function is allowed. I'll post my solution (although it's a sloppy solution and I think a better one exists) before I go to class in 30 mins if no one else comes up an answer.

cookie
10-04-2005, 05:21 PM
[ QUOTE ]
Only one function is allowed. I'll post my solution (although it's a sloppy solution and I think a better one exists) before I go to class in 30 mins if no one else comes up an answer.

[/ QUOTE ]
Yeah also thought the double function solution seemed to easy...

Homer
10-04-2005, 05:22 PM
[ QUOTE ]
I came across this problem while doing my Calc hw today. Took me awhile to get it, I thought it was a pretty neat problem.

Find a formula for the nth term of this sequence.
0, 1, 1, 2, 2, 3, 3, 4, 4, ... (each positive integer repeated).

The whole time I was doing this I was thinking about how much easier it would be to just write a C code for it, damn calculus and it's lack of ability to round down to the nearest factor of 2. Enjoy.

[/ QUOTE ]

{n + (-1)^n)}/2

EDIT - [censored], that's wrong.

BruceZ
10-04-2005, 05:26 PM
[ QUOTE ]
[ QUOTE ]
[ QUOTE ]
I came across this problem while doing my Calc hw today. Took me awhile to get it, I thought it was a pretty neat problem.

Find a formula for the nth term of this sequence.
0, 1, 1, 2, 2, 3, 3, 4, ... (each positive integer repeated).

The whole time I was doing this I was thinking about how much easier it would be to just write a C code for it, damn calculus and it's lack of ability to round down to the nearest factor of 2. Enjoy.

Edit - fixed sequence typo, and edited to add no using mod or anything such as that. Only standard math terms, ie. + , - , x , divide, and powers.

[/ QUOTE ]

f(n) = n/2 for n even
f(n) = (n+1)/2 for n odd

[/ QUOTE ]
f(n) = (n+1)/2 for n odd should be (n-1)/2, right?

[/ QUOTE ]

No, f(0) = 0, f(1) = 1, unless you want to start from f(1), and then it would be (n-1)/2.

One equation? OK, f(n) = {n + [1 - (-1)^n]/2}/2

Or if you start from f(1) = 0, then f(n) = {n - [1 - (-1)^n]/2}/2

Homer
10-04-2005, 05:28 PM
Damn, I hate you Bruce. /images/graemlins/smile.gif

I was getting close, but couldn't figure out how to turn the odd n terms to even without changing the even n terms. Basically, this part is where I was stuck -> [1 - (-1)^n]/2

-- Homer

cookie
10-04-2005, 05:28 PM
why isnt it like:
N: 1 2 3 4 5 6 7 8 9
...0 1 1 2 2 3 3 4 4

???

TBag
10-04-2005, 05:36 PM
[ QUOTE ]
why isnt it like:
N: 1 2 3 4 5 6 7 8 9
...0 1 1 2 2 3 3 4 4

???

[/ QUOTE ]

The book doesn't specify, but I'm pretty sure it's supposed to be like that.

My answer is in white below:
<font color="white"> n/2 - [1 - (-1)^n ]/4
n &gt;= 1 </font>

BruceZ
10-04-2005, 05:48 PM
[ QUOTE ]
[ QUOTE ]
why isnt it like:
N: 1 2 3 4 5 6 7 8 9
...0 1 1 2 2 3 3 4 4

???

[/ QUOTE ]

The book doesn't specify, but I'm pretty sure it's supposed to be like that.

My answer is in white below:
<font color="white"> n/2 - [1 - (-1)^n ]/4
n &gt;= 1 </font>

[/ QUOTE ]

That's the same as my second solution if you break mine into two terms.

It's arbitrary whether you start counting from 0 or 1. Math people usually start from 1, while computer science people index arrays from 0.

Cosimo
10-04-2005, 06:08 PM
grunching.

-1^n : 1 -1 1 -1 1 -1
2n 0 2 4 6 8 10
+ 1 1 5 5 9 9

so,

(2n+(-1^n)-1)/4

produces 0 1 1 2 2 ... etc for n=1..infinity

10-04-2005, 06:11 PM
[ QUOTE ]
I came across this problem while doing my Calc hw today. Took me awhile to get it, I thought it was a pretty neat problem.

Find a formula for the nth term of this sequence.
0, 1, 1, 2, 2, 3, 3, 4, ... (each positive integer repeated).

The whole time I was doing this I was thinking about how much easier it would be to just write a C code for it, damn calculus and it's lack of ability to round down to the nearest factor of 2. Enjoy.

Edit - fixed sequence typo, and edited to add no using mod or anything such as that. Only standard math terms, ie. + , - , x , divide, and powers.

Edited again to say that you can only use one function that will apply to your whole sequence, no dividing odds and evens between two seperate functions.

[/ QUOTE ]



What math is this?