Re: For all you math puzzle nuts...
[ 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
|