Discussion about math, puzzles, games and fun. Useful symbols: ÷ × ½ √ ∞ ≠ ≤ ≥ ≈ ⇒ ± ∈ Δ θ ∴ ∑ ∫ π -¹ ² ³ °

You are not logged in.

- Topics: Active | Unanswered

**phrontister****Real Member**- From: The Land of Tomorrow
- Registered: 2009-07-12
- Posts: 4,460

Hi Bobby,

Thanks!

Here's my code:

*Last edited by phrontister (2012-09-08 05:56:38)*

"The good news about computers is that they do what you tell them to do. The bad news is that they do what you tell them to do." - Ted Nelson

Offline

**bobbym****Administrator**- From: Bumpkinland
- Registered: 2009-04-12
- Posts: 107,163

Hi phrontister;

**In mathematics, you don't understand things. You just get used to them.****If it ain't broke, fix it until it is.**** Always satisfy the Prime Directive of getting the right answer above all else.**

Offline

**phrontister****Real Member**- From: The Land of Tomorrow
- Registered: 2009-07-12
- Posts: 4,460

Hi Bobby,

You've probably spotted this already in my M, but sums of any other terms can be found too just by changing the value of 'x'.

I can't remember now what steps I used to get the final M, but it started out more verbose and more logical-looking (to me) until I saw it could be simplified to what it is now. Unfortunately my scribblings are now ashes in the wood heater.

"The good news about computers is that they do what you tell them to do. The bad news is that they do what you tell them to do." - Ted Nelson

Offline

**bobbym****Administrator**- From: Bumpkinland
- Registered: 2009-04-12
- Posts: 107,163

Hi;

It is fine. You could have shortened it just a little.

**In mathematics, you don't understand things. You just get used to them.****If it ain't broke, fix it until it is.**** Always satisfy the Prime Directive of getting the right answer above all else.**

Offline

**phrontister****Real Member**- From: The Land of Tomorrow
- Registered: 2009-07-12
- Posts: 4,460

How, Bobby?

"The good news about computers is that they do what you tell them to do. The bad news is that they do what you tell them to do." - Ted Nelson

Offline

**bobbym****Administrator**- From: Bumpkinland
- Registered: 2009-04-12
- Posts: 107,163

**In mathematics, you don't understand things. You just get used to them.****If it ain't broke, fix it until it is.**** Always satisfy the Prime Directive of getting the right answer above all else.**

Offline

**phrontister****Real Member**- From: The Land of Tomorrow
- Registered: 2009-07-12
- Posts: 4,460

Ok, I'll have to think about that.

Yes, I did see that my code would choke on a bigger piece of steak, but as it was able to swallow the tidbit that I fed it I just left it there. No ideas immediately spring to mind, and I don't know where to start looking yet....(maybe I should read the M manual..but I haven't got forever).

Must go...miles of paperwork to do, so I should do it.

Edit: Just saw your edited reply...so that might help. Ta.

*Last edited by phrontister (2012-09-09 16:13:27)*

Offline

**bobbym****Administrator**- From: Bumpkinland
- Registered: 2009-04-12
- Posts: 107,163

Hi;

I modified the above post while you were posting. Work on it a little yourself and then I will show it to you when you get back.

**In mathematics, you don't understand things. You just get used to them.****If it ain't broke, fix it until it is.**** Always satisfy the Prime Directive of getting the right answer above all else.**

Offline

**phrontister****Real Member**- From: The Land of Tomorrow
- Registered: 2009-07-12
- Posts: 4,460

I just saw your edit and edited my post a couple of seconds after your last post. We could cross-post all day long!

*Last edited by phrontister (2012-09-09 16:15:51)*

Offline

**bobbym****Administrator**- From: Bumpkinland
- Registered: 2009-04-12
- Posts: 107,163

Hi;

It is a pain in the neck when that happens.

replace this:

Total[Table[Prime[n], {n, x}]]

with

Sum[Prime[k],{k,1,x}]

I like the way you easily made the jump from Basic's procedural style to the functional style that M supports. It is usually a difficult transition. But in this case M's mathematical style is even better. Sum is equivalent to sigma in mathematics.

**In mathematics, you don't understand things. You just get used to them.****If it ain't broke, fix it until it is.**** Always satisfy the Prime Directive of getting the right answer above all else.**

Offline

**phrontister****Real Member**- From: The Land of Tomorrow
- Registered: 2009-07-12
- Posts: 4,460

Hi Bobby,

Yes, that change works well. I tried my code at 80 million but ran out of memory...like you said. Your code found the answer, taking just over 5 minutes.

Thanks for opening my eyes to that improvement.

Sum is equivalent to sigma in mathematics.

The only Sigma I know is a Mitsubishi, but I don't think that 'counts'. I looked it up on the net and realise that either I was asleep in class when it was taught or it wasn't taught in my class...or, more likely, *I* wasn't taught in my class. But then I shouldn't have been reading Thomas Hardy hidden inside my maths book, should I?

I think I follow some of the drift (and I also think that either you or anonimnystefy tried to explain something or other about it to me once), but as I never used that knowledge again, well......you know the rest.

Offline

**bobbym****Administrator**- From: Bumpkinland
- Registered: 2009-04-12
- Posts: 107,163

Sigma or summation notation is nothing amazing the symbol looks like this:

all that says is starting from 1 to 1000000 put each in k and add em up. You only keep one number in memory.

**In mathematics, you don't understand things. You just get used to them.****If it ain't broke, fix it until it is.**** Always satisfy the Prime Directive of getting the right answer above all else.**

Offline

**phrontister****Real Member**- From: The Land of Tomorrow
- Registered: 2009-07-12
- Posts: 4,460

Thanks, Bobby...that's pretty clear.

Now that I see it expressed like that I reckon I was right before in saying that you or stefy tried to teach me something about it.

Btw, I tried to run your code for the 1,000 millionth term, but after 2 hours of blazing effort and nothing to show for it I put it out of its misery.

I guess the larger prime sizes were progressively taking their toll.

Offline

**bobbym****Administrator**- From: Bumpkinland
- Registered: 2009-04-12
- Posts: 107,163

There are limits to what can achieved even with modern computers.

**In mathematics, you don't understand things. You just get used to them.****If it ain't broke, fix it until it is.**** Always satisfy the Prime Directive of getting the right answer above all else.**

Offline

**phrontister****Real Member**- From: The Land of Tomorrow
- Registered: 2009-07-12
- Posts: 4,460

Maybe I'll flick-pass this over to Scott Flansburg, then. I wouldn't want to overstress my indispensable time-saving device.

Offline

**bobbym****Administrator**- From: Bumpkinland
- Registered: 2009-04-12
- Posts: 107,163

Hi phrontister;

Just means that to solve a problem that big we would have to come up with something faster. Anyway, you did well.

But then I shouldn't have been reading Thomas Hardy hidden inside my maths book

I did some of that too. Trouble is you will someday end up on a math forum and have to do it then.

**In mathematics, you don't understand things. You just get used to them.****If it ain't broke, fix it until it is.**** Always satisfy the Prime Directive of getting the right answer above all else.**

Offline

**phrontister****Real Member**- From: The Land of Tomorrow
- Registered: 2009-07-12
- Posts: 4,460

Hi Bobby,

Reading the future into the past! Well, then I'd hope to find one with helpful members who know their stuff and can pass it on!

Offline

**bobbym****Administrator**- From: Bumpkinland
- Registered: 2009-04-12
- Posts: 107,163

Hi;

Didn't work out that way for me. Had to do it all by myself. Nothing harder than trying to train an old dog to hunt.

**In mathematics, you don't understand things. You just get used to them.****If it ain't broke, fix it until it is.**** Always satisfy the Prime Directive of getting the right answer above all else.**

Offline

**phrontister****Real Member**- From: The Land of Tomorrow
- Registered: 2009-07-12
- Posts: 4,460

Good ol' Tulip turned up its nose when I said I was going to teach it to hunt, with the idea that we would go to Utopia together to track down one of these forums.

I can't hunt without Tulip, so my search is over before it started.

*Last edited by phrontister (2012-09-10 21:09:59)*

Offline

**bobbym****Administrator**- From: Bumpkinland
- Registered: 2009-04-12
- Posts: 107,163

Tulip, is that the dog with the cheese?

Wait, I remember now, you said that dog was not Tulip. So, I have never seen a picture of him/her.

**In mathematics, you don't understand things. You just get used to them.****If it ain't broke, fix it until it is.**** Always satisfy the Prime Directive of getting the right answer above all else.**

Offline

**phrontister****Real Member**- From: The Land of Tomorrow
- Registered: 2009-07-12
- Posts: 4,460

Ah...the memories! Remember Tu and phro?

Tulip, is that the dog with the cheese?

No, *I'm* the one with the cheese...and I'm not a dog.

Tulip did this with the cheese...

...which was after having done that to it. Well, something like what that ugly mutt (not Tulip, of course!!) did with the cheese, anyway.

So, I have never seen a picture of him/her.

Neither have I. Tulip is very modest and always declines to have its picture taken.

...him/her.

This answers that gender question.

*Last edited by phrontister (2012-09-10 22:07:26)*

Offline

**bobbym****Administrator**- From: Bumpkinland
- Registered: 2009-04-12
- Posts: 107,163

Yes, I remember that but now I am more confused than ever. Unknown gender, no known photographs...

**In mathematics, you don't understand things. You just get used to them.****If it ain't broke, fix it until it is.**** Always satisfy the Prime Directive of getting the right answer above all else.**

Offline

**phrontister****Real Member**- From: The Land of Tomorrow
- Registered: 2009-07-12
- Posts: 4,460

And well may you be confused: Tulip is one of eleven of the 10 Greatest Unsolved Mysteries of the World.

*Last edited by phrontister (2012-09-10 23:56:16)*

Offline

**bobbym****Administrator**- From: Bumpkinland
- Registered: 2009-04-12
- Posts: 107,163

Hmmm. I am still trying to figure out who the heck phro is. Why did you choose that video of that dog?

**In mathematics, you don't understand things. You just get used to them.****If it ain't broke, fix it until it is.**** Always satisfy the Prime Directive of getting the right answer above all else.**

Offline

**phrontister****Real Member**- From: The Land of Tomorrow
- Registered: 2009-07-12
- Posts: 4,460

Hmmm. I am still trying to figure out who the heck phro is.

Me. 'phro' is Tigeree's shortened version of 'phrontister'. See here. Is she a slow typist?

Why did you choose that video of that dog?

That video was the closest thing that I could find on the net to demonstrate what Tulip does in that move. I'd just snatched the cheese from Tigeree and gave it to Tulip for safekeeping. See here.

Tulip and I had perfected a routine whereby I could keep something away from a would-be possessor just by placing it on Tulip's nose, and if that wasn't enough deterrent I'd simply issue a vocal command and with lightning speed Tulip would move its head sideways and catch the object in its mouth...where it would then remain undisturbed until I gave Tulip the command to release it to me.

Works every time...and it was great for keeping the cheese out of Tigeree's clutches!

*Last edited by phrontister (2012-09-10 23:47:13)*

Offline