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

You are not logged in.

- Topics: Active | Unanswered

**anonimnystefy****Real Member**- From: The Foundation
- Registered: 2011-05-23
- Posts: 15,544

M is Mathematica.

Here lies the reader who will never open this book. He is forever dead.

Taking a new step, uttering a new word, is what people fear most. ― Fyodor Dostoyevsky, Crime and Punishment

Offline

Why not Maxima?

By the way, you also asked whether you can call bobbym as 'M'

'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'

'You have made another human being happy. There is no greater accomplishment.' -bobbym

Offline

**anonimnystefy****Real Member**- From: The Foundation
- Registered: 2011-05-23
- Posts: 15,544

Let me introduce you to the nomenclature:

M-Mathematica

m-bobbym and his two male predecessors.

Here lies the reader who will never open this book. He is forever dead.

Taking a new step, uttering a new word, is what people fear most. ― Fyodor Dostoyevsky, Crime and Punishment

Offline

Ok

Why not Maxima?

'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'

'You have made another human being happy. There is no greater accomplishment.' -bobbym

Offline

**anonimnystefy****Real Member**- From: The Foundation
- Registered: 2011-05-23
- Posts: 15,544

Because it is the currently used nomenclature.

Here lies the reader who will never open this book. He is forever dead.

Taking a new step, uttering a new word, is what people fear most. ― Fyodor Dostoyevsky, Crime and Punishment

Offline

**bobbym****Administrator**- From: Bumpkinland
- Registered: 2009-04-12
- Posts: 87,237

In order to design an algorithm I still need an answer to the question of what numbers are permitted.

**In mathematics, you don't understand things. You just get used to them.Of course that result can be rigorously obtained, but who cares?Combinatorics is Algebra and Algebra is Combinatorics.**

Offline

**anonimnystefy****Real Member**- From: The Foundation
- Registered: 2011-05-23
- Posts: 15,544

He answered that on the previous page...

Here lies the reader who will never open this book. He is forever dead.

Offline

**bobbym****Administrator**- From: Bumpkinland
- Registered: 2009-04-12
- Posts: 87,237

It might be there and then again it might not.

**In mathematics, you don't understand things. You just get used to them.Of course that result can be rigorously obtained, but who cares?Combinatorics is Algebra and Algebra is Combinatorics.**

Offline

**anonimnystefy****Real Member**- From: The Foundation
- Registered: 2011-05-23
- Posts: 15,544

Agnishom wrote:

Any thing .... Just liike bobbym does in Add 99 and post forever

Here lies the reader who will never open this book. He is forever dead.

Offline

**bobbym****Administrator**- From: Bumpkinland
- Registered: 2009-04-12
- Posts: 87,237

Then I might suggest a greedy algorithm.

**In mathematics, you don't understand things. You just get used to them.Of course that result can be rigorously obtained, but who cares?Combinatorics is Algebra and Algebra is Combinatorics.**

Offline

**anonimnystefy****Real Member**- From: The Foundation
- Registered: 2011-05-23
- Posts: 15,544

anonimnystefy wrote:

See this: http://www.alpertron.com.ar/4SQUARES.HTM

Have you checked this link? It can be done by recursion.

Here lies the reader who will never open this book. He is forever dead.

Offline

**bobbym****Administrator**- From: Bumpkinland
- Registered: 2009-04-12
- Posts: 87,237

Recursion: anything done by it can always be done better in another way.

Of course that result can be rigorously obtained, but who cares?

Combinatorics is Algebra and Algebra is Combinatorics.

Offline

**anonimnystefy****Real Member**- From: The Foundation
- Registered: 2011-05-23
- Posts: 15,544

Maybe, but it's a start. And it is definitely better than brute force.

Speaking of recursion, does M do memoization while running a recursion?

Here lies the reader who will never open this book. He is forever dead.

Offline

**bobbym****Administrator**- From: Bumpkinland
- Registered: 2009-04-12
- Posts: 87,237

Yes, see the examples on Fibonacci numbers I think.

I am going offline for a while.

Of course that result can be rigorously obtained, but who cares?

Combinatorics is Algebra and Algebra is Combinatorics.

Offline

**anonimnystefy****Real Member**- From: The Foundation
- Registered: 2011-05-23
- Posts: 15,544

Okay, see you later.

Here lies the reader who will never open this book. He is forever dead.

Offline

Hm, A greedy algorithm is like what?

'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'

'You have made another human being happy. There is no greater accomplishment.' -bobbym

Offline

**anonimnystefy****Real Member**- From: The Foundation
- Registered: 2011-05-23
- Posts: 15,544

Hi bobbym

If we are working in a language which does memoization in recursions, recursion will suffice.

If not, a DP type solution will do.

Here lies the reader who will never open this book. He is forever dead.

Offline

**bobbym****Administrator**- From: Bumpkinland
- Registered: 2009-04-12
- Posts: 87,237

Hi anonimnystefy;

If not, a DP type solution will do

DP?

Hi Agnishom;

Basically, take the biggest square you can out each time.

Of course that result can be rigorously obtained, but who cares?

Combinatorics is Algebra and Algebra is Combinatorics.

Offline

**anonimnystefy****Real Member**- From: The Foundation
- Registered: 2011-05-23
- Posts: 15,544

Dynamic programming. Basically, we will do all values from 1 to n, and it will be O(n) because we can calculate a value in O(1) when we have the previous values.

Here lies the reader who will never open this book. He is forever dead.

Offline

**bobbym****Administrator**- From: Bumpkinland
- Registered: 2009-04-12
- Posts: 87,237

Because he is allowing multiplicities and zero he is guaranteeing that every number is the sum of 4 squares.

17 = 4^2 + 1^2 + 0^2 + 0^2

17 = 3^2 + 2^2 + 2^2 + 0^2

Of course that result can be rigorously obtained, but who cares?

Combinatorics is Algebra and Algebra is Combinatorics.

Offline

**anonimnystefy****Real Member**- From: The Foundation
- Registered: 2011-05-23
- Posts: 15,544

I was suggesting an algorithm in post #45. I do not know how you got anything else from that post...

Your greedy algorithm doesn't work for 1022 (and probably many more numbers).

Here lies the reader who will never open this book. He is forever dead.

Offline

**bobbym****Administrator**- From: Bumpkinland
- Registered: 2009-04-12
- Posts: 87,237

Not so!

Done by hand!

Of course that result can be rigorously obtained, but who cares?

Combinatorics is Algebra and Algebra is Combinatorics.

Offline

**anonimnystefy****Real Member**- From: The Foundation
- Registered: 2011-05-23
- Posts: 15,544

Yes, but that is not what your algorithm gets. The largest square below 1022 is 961=31^2.

Here lies the reader who will never open this book. He is forever dead.

Offline

**bobbym****Administrator**- From: Bumpkinland
- Registered: 2009-04-12
- Posts: 87,237

You do not have to stop there. When 31 does not work you try 30 which does. Algorithm is very fast.

Of course that result can be rigorously obtained, but who cares?

Combinatorics is Algebra and Algebra is Combinatorics.

Offline

I see, can you explain the structure of your greedy algorithm more clearly?

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

'You have made another human being happy. There is no greater accomplishment.' -bobbym

Offline