You are not logged in.

- Topics: Active | Unanswered

**Mrwhy****Member**- Registered: 2012-07-02
- Posts: 52

Do I understand you want 4 squares that sum to 130

I must have got summat wrong (as usual!)

The "algorithm" is "Write a program that tries ALL the numbers up to 12 (13 is to big for on its own its square exceeds 130"

Writing the prog takes 60 seconds - running it takes milliseconds.

I assume you want all different integers

How about

1 4 7 8

1 2 5 10

2 3 6 9

and so on

I must have completely misunderstood!

Offline

**bobbym****Administrator**- From: Bumpkinland
- Registered: 2009-04-12
- Posts: 105,249

Hey, that guy has the same name as you.

**In mathematics, you don't understand things. You just get used to them.****If it ain't broke, fix it until it is.****No great discovery was ever made without a bold guess. **

Offline

Which guy?

Hi Mrwhy,

What you are twlling me is the brute-force approach, but I need a better approach than that to tackle larger numbers

'And fun? If maths is fun, then getting a tooth extraction is fun. A viral infection is fun. Rabies shots are fun.'

'God exists because Mathematics is consistent, and the devil exists because we cannot prove it'

I'm not crazy, my mother had me tested.

Offline

**bobbym****Administrator**- From: Bumpkinland
- Registered: 2009-04-12
- Posts: 105,249

Hi Agnishom;

I am not finding the error in the code that is leaving out 130.

We could run through your algorithm by hand checking it against mine for each step. Using the 130 as the test number.

**In mathematics, you don't understand things. You just get used to them.****If it ain't broke, fix it until it is.****No great discovery was ever made without a bold guess. **

Offline

Or maybe running the debugger..

There is only one **Agnishom**. That tumblr. was mine

'And fun? If maths is fun, then getting a tooth extraction is fun. A viral infection is fun. Rabies shots are fun.'

'God exists because Mathematics is consistent, and the devil exists because we cannot prove it'

I'm not crazy, my mother had me tested.

Offline

**bobbym****Administrator**- From: Bumpkinland
- Registered: 2009-04-12
- Posts: 105,249

I know that was you. I was kidding.

You can use the debugger to single step the code.

I am taking a little break, see you in a bit.

**In mathematics, you don't understand things. You just get used to them.****If it ain't broke, fix it until it is.****No great discovery was ever made without a bold guess. **

Offline

**Mrwhy****Member**- Registered: 2012-07-02
- Posts: 52

Agnishom wrote:

Which guy?

Hi Mrwhy,

What you are twlling me is the brute-force approach, but I need a better approach than that to tackle larger numbers

The best method depends on the tools you have!

How big a number

How many milliseconds do you have?

How about all N up to 100,million?

I did not even optimise my search.

What is the point in spending one minute longer writing a better algorithm just to have the prog run in 0.0001 sec instead of 0.001

We can afford MANY seconds - our computers are ever willing ever stupid and ENJOY IT!

EXPERIMENTAL MATHS is FUN - the computer does all the boring bits!

No teeth being extracted at all!

*Last edited by Mrwhy (2013-04-21 08:09:24)*

Offline

**bobbym****Administrator**- From: Bumpkinland
- Registered: 2009-04-12
- Posts: 105,249

Hi;

What is the point in spending one minute longer writing a better algorithm just to have the prog run in 0.0001 sec instead of 0.001

There is only one really good reason, practice for when you need the skill. Many times problems in combinatorics will have say 20 or 25 factorial different possibilities. Number theory is even worse. You can not always plow through some immense number.

Take this problem which is really about numbers around 40000+ The 130 is just for an example. The simplest approach of 4 loops could require

200^4 checks, that is not an insignificant number. Also, the numbers are getting bigger for what he wants those squares for.

**In mathematics, you don't understand things. You just get used to them.****If it ain't broke, fix it until it is.****No great discovery was ever made without a bold guess. **

Offline

and my algorithm breaks ten digits number in less than a second, I have checked it.

'And fun? If maths is fun, then getting a tooth extraction is fun. A viral infection is fun. Rabies shots are fun.'

'God exists because Mathematics is consistent, and the devil exists because we cannot prove it'

I'm not crazy, my mother had me tested.

Offline

**bobbym****Administrator**- From: Bumpkinland
- Registered: 2009-04-12
- Posts: 105,249

Do you have an example?

**In mathematics, you don't understand things. You just get used to them.****If it ain't broke, fix it until it is.****No great discovery was ever made without a bold guess. **

Offline

Of course, give me a number

'God exists because Mathematics is consistent, and the devil exists because we cannot prove it'

I'm not crazy, my mother had me tested.

Offline

**bobbym****Administrator**- From: Bumpkinland
- Registered: 2009-04-12
- Posts: 105,249

I have a nice 9 digit number:

124701084

**In mathematics, you don't understand things. You just get used to them.****If it ain't broke, fix it until it is.****No great discovery was ever made without a bold guess. **

Offline

8340, 7426, 2, 2

'God exists because Mathematics is consistent, and the devil exists because we cannot prove it'

I'm not crazy, my mother had me tested.

Offline

**bobbym****Administrator**- From: Bumpkinland
- Registered: 2009-04-12
- Posts: 105,249

Correct a Mundo!

**In mathematics, you don't understand things. You just get used to them.****If it ain't broke, fix it until it is.****No great discovery was ever made without a bold guess. **

Offline

*Last edited by Agnishom (2013-04-22 13:43:58)*

'God exists because Mathematics is consistent, and the devil exists because we cannot prove it'

I'm not crazy, my mother had me tested.

Offline

**bobbym****Administrator**- From: Bumpkinland
- Registered: 2009-04-12
- Posts: 105,249

You obviously got it working.

**In mathematics, you don't understand things. You just get used to them.****If it ain't broke, fix it until it is.****No great discovery was ever made without a bold guess. **

Offline

Is there any specific reason you call it nice?

'God exists because Mathematics is consistent, and the devil exists because we cannot prove it'

I'm not crazy, my mother had me tested.

Offline

**bobbym****Administrator**- From: Bumpkinland
- Registered: 2009-04-12
- Posts: 105,249

Yes, because it can be broken down into squares that are repunits.

**In mathematics, you don't understand things. You just get used to them.****If it ain't broke, fix it until it is.****No great discovery was ever made without a bold guess. **

Offline

Repunits?

'God exists because Mathematics is consistent, and the devil exists because we cannot prove it'

I'm not crazy, my mother had me tested.

Offline

**bobbym****Administrator**- From: Bumpkinland
- Registered: 2009-04-12
- Posts: 105,249

Numbers with all 1's in them.

**In mathematics, you don't understand things. You just get used to them.****If it ain't broke, fix it until it is.****No great discovery was ever made without a bold guess. **

Offline

I guess this is much better than Mrwhy's

'God exists because Mathematics is consistent, and the devil exists because we cannot prove it'

I'm not crazy, my mother had me tested.

Offline

**bobbym****Administrator**- From: Bumpkinland
- Registered: 2009-04-12
- Posts: 105,249

Hi;

He has a good point though. A long time ago a very brilliant kid wrote a paper entitled "Commonsense Brute Force and the Computer."

In it he outlined pretty much the same viewpoint.

**In mathematics, you don't understand things. You just get used to them.****If it ain't broke, fix it until it is.****No great discovery was ever made without a bold guess. **

Offline

Hmm, how was the kid like?

'God exists because Mathematics is consistent, and the devil exists because we cannot prove it'

I'm not crazy, my mother had me tested.

Offline

**bobbym****Administrator**- From: Bumpkinland
- Registered: 2009-04-12
- Posts: 105,249

Smart, but very rebellious.

**In mathematics, you don't understand things. You just get used to them.****If it ain't broke, fix it until it is.****No great discovery was ever made without a bold guess. **

Offline

How did he use to spend his free time?

'God exists because Mathematics is consistent, and the devil exists because we cannot prove it'

I'm not crazy, my mother had me tested.

Offline