Mathematica CodeWatch

#1
How would you write the code for finding n such that the Harmonic Series is greater than 10? i.e

I've got 2^17 from fiddling with inequalities, which obviously works, but it's well above 10 at around 12.36 (since I discarded so many fractions).

So any idea? Tried it with 'Solve' but that won't work.
Just curious and I do need to improve my usage of this program!

Thanks

Edit: The answer is n>=12367 on Wolfram.
0
10 years ago
#2
Try solving with equality (because computer algebra packages use methods which makes that okay).

Not sure about Mathematica, but in Maple you would write:

evalf(solve(sum(1/k, k=1..n)=10, n));

12366.46811

So clearly the solution is .
0
#3
(Original post by James)
Try solving with equality (because computer algebra packages use methods which makes that okay).

Not sure about Mathematica, but in Maple you would write:

evalf(solve(sum(1/k, k=1..n)=10, n));

12366.46811

So clearly the solution is .
Tried it a few different ways on Mathematica (including with the equality), it doesn't seem to work. Ah well, thanks anyway.
0
10 years ago
#4
Code:
sum = 0;
n = 0;
While[sum < 10, {n = n + 1, sum = sum + 1/n}]
n
sum // N
0
#5
(Original post by nota bene)
Code:
sum = 0;
n = 0;
While[sum < 10, {n = n + 1, sum = sum + 1/n}]
n
sum // N
Neat.
I need to learn how to program on mathematica. The 'While' and 'Do' commands were introduced this week, i'm hopeless...
Thanks
0
10 years ago
#6
(Original post by silent ninja)
I need to learn how to program on mathematica. The 'While' and 'Do' commands were introduced this week, i'm hopeless...
Same here - I had to ask a friend how to do when I had two bodies to run the test on, but apparently it was just to put it in as a table; that's why it took me nearly a week to reply
0
#7
(Original post by nota bene)
Same here - I had to ask a friend how to do when I had two bodies to run the test on, but apparently it was just to put it in as a table; that's why it took me nearly a week to reply
Glad you remembered to post back then!

Not looking forward to my mathematica project over the holidays I hope you are still around!
0
X

new posts
Latest
My Feed

Oops, nobody has postedin the last few hours.

Why not re-start the conversation?

see more

See more of what you like onThe Student Room

You can personalise what you see on TSR. Tell us a little about yourself to get started.

University open days

• University of the Arts London
MA Performance Design and Practice Open Day Postgraduate
Thu, 24 Jan '19
• Brunel University London
Sat, 26 Jan '19
• SOAS University of London
Sat, 26 Jan '19

Poll

Join the discussion

Are you chained to your phone?

Yes (75)
19.43%
Yes, but I'm trying to cut back (156)
40.41%
Nope, not that interesting (155)
40.16%