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

You are not logged in.

- Topics: Active | Unanswered

How do you do this using non-mathematical languages or without the FindInstance command?

'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

**bobbym****Administrator**- From: Bumpkinland
- Registered: 2009-04-12
- Posts: 93,935

There is a program on the net in C++. You could use the greedy algorithm.

**In mathematics, you don't understand things. You just get used to them.**

**I agree with you regarding the satisfaction and importance of actually computing some numbers. I can't tell you how often I see time and money wasted because someone didn't bother to run the numbers.**

Offline

C++? I have no idea how to do big integer arithmetic with 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'

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

Offline

**bobbym****Administrator**- From: Bumpkinland
- Registered: 2009-04-12
- Posts: 93,935

I was not aware that it supported anything bigger than a long double?

**In mathematics, you don't understand things. You just get used to them.**

**I agree with you regarding the satisfaction and importance of actually computing some numbers. I can't tell you how often I see time and money wasted because someone didn't bother to run the numbers.**

Offline

There might be some way to do that. I do not want to do it again, I already did it last year.

Can we do it in M without the FindInstance command ?

'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

**bobbym****Administrator**- From: Bumpkinland
- Registered: 2009-04-12
- Posts: 93,935

You could use procedural commands just like you did in C++. But unless that is faster, I would stick with FI.

**In mathematics, you don't understand things. You just get used to them.**

**I agree with you regarding the satisfaction and importance of actually computing some numbers. I can't tell you how often I see time and money wasted because someone didn't bother to run the numbers.**

Offline

When did I do anything in C++? FindInstance did not help me learn anything new

'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

**bobbym****Administrator**- From: Bumpkinland
- Registered: 2009-04-12
- Posts: 93,935

Whatever language you programmed it in before. M has the procedural paradigm too.

FindInstance did not help me learn anything new

You saw how to use a very powerful command, that is nothing? What are you trying to learn?

**In mathematics, you don't understand things. You just get used to them.**

Offline

I am trying to learn how such algorithms work.

'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

**bobbym****Administrator**- From: Bumpkinland
- Registered: 2009-04-12
- Posts: 93,935

There is no known algorithm that specifically does that job. I think they just use the greedy algorithm.

**In mathematics, you don't understand things. You just get used to them.**

Offline

Okay teach me the greedy algorithm

'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

**bobbym****Administrator**- From: Bumpkinland
- Registered: 2009-04-12
- Posts: 93,935

Take the biggest square you can, subtract it from the number, repeat this process with the new number.

**In mathematics, you don't understand things. You just get used to them.**

Offline

Probably a good idea, but there can be faster algorithms for this problem

'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

**bobbym****Administrator**- From: Bumpkinland
- Registered: 2009-04-12
- Posts: 93,935

What are they?

**In mathematics, you don't understand things. You just get used to them.**

Offline

How am I supposed to know? I am only a bumpkin

'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

**bobbym****Administrator**- From: Bumpkinland
- Registered: 2009-04-12
- Posts: 93,935

What is that?

**In mathematics, you don't understand things. You just get used to them.**

Offline

ask bobbym

'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

**bobbym****Administrator**- From: Bumpkinland
- Registered: 2009-04-12
- Posts: 93,935

He went downstairs.

**In mathematics, you don't understand things. You just get used to them.**

Offline

Call him on his mobile phone.

'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

**bobbym****Administrator**- From: Bumpkinland
- Registered: 2009-04-12
- Posts: 93,935

He does not have a mobile phone, I am starting to get worried about him.

**In mathematics, you don't understand things. You just get used to them.**

Offline

Call him up on his Mathematica

'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

**bobbym****Administrator**- From: Bumpkinland
- Registered: 2009-04-12
- Posts: 93,935

Oh, he is back. He said they did not care for the name question but they told him there are a few math tricks but no known algorithm to do it.

**In mathematics, you don't understand things. You just get used to them.**

Offline

Why is this not working:

`FindInstance[7==a+b && PrimeQ[a] && PrimeQ[b],{a,b}, Integers]`

'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

**bobbym****Administrator**- From: Bumpkinland
- Registered: 2009-04-12
- Posts: 93,935

Perhaps you should bound the problem a little better.

```
FindInstance[{a > 0, b > 0, a \[Element] Primes, b \[Element] Primes,
a + b == 7}, {a, b}, Integers, 3]
```

{{a -> 2, b -> 5}, {a -> 5, b -> 2}}

**In mathematics, you don't understand things. You just get used to them.**

Offline

Why is my code wrong?

'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