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

You are not logged in.

- Topics: Active | Unanswered

Hi EbenezerSon;

You can easily find all your posts by one of the following 2 methods.

Method 1:

- Log in, and click 'Profile' in the header bar near the top of the page.

- The Essentials page of the 'Profile menu' page should then display, but if it doesn't, click 'Essentials' in the menu on the left.

- Click 'Show all posts' in the 'User activity' panel that's near the bottom of the page.

Your posts will then be displayed, in descending date order, on the next page - 'Index » Search » Posts by EbenezerSon' - or over multiple pages if they don't all fit on 1 page.

The header bar above each post contains links to the respective forum, topic and post pages.

Method 2:

- Whether you are logged in or not, click on your 'live' name in the left-hand-side panel of any of your posts to access your profile page, and click 'Show all posts' in the 'User activity' panel.

Topics:

- To find all your topics instead, just select 'Show all topics' in the final step of either method.

Other members:

- Method 2 can be used to find posts and topics of other members too, by clicking on their 'live' name in one of their posts.

I hope that clears it up for you.

Thanks, Bob...I'll watch out for such!

Or are you playing 'Spot the Oxymoron'?

Here's a solution (I think) using the permutations formula.

And there I was thinking that you were just testing me to see if I'd notice you'd only done half the job!

I feel your pain, having lasted just one minute of listening to the Brexit news that I woke up to this morning (yes, we down here sometimes hear about overseas goings-on too).

Hi Bob,

I like your strategy, but VCVCCV and VCCVCV are also valid arrangements because the constraint on adjacent letters only applies to vowels.

Those are the only other arrangements I could find.

That would double your answer, I think.

Hi Zeeshan 01;

Zeeshan 01 wrote:

Any one can print this

******* *******

****** * ******

***** * *****

**** * * * ****

*** * ***

** * **

* *

I thought I'd give your new puzzle a go, but unlike with your original puzzle, a simple solution has me stumped this time because it seems to lack symmetry now that you've added that internal cross. It's trickier now...hence your change of the thread title from "Help in simple prob of loop" to "Complex Loop", I suppose.

Zeeshan 01 wrote:

Thanks for help but I need c language code

I still don't know c, nor the other two programming languages you mentioned (cpp and Java); but anyway, in case it helps someone, here's my effort in BASIC, based on my first solution to your original puzzle:

*EDIT: It's closer to the second solution, actually.*

```
a$="*******":c=7
WHILE c>0
IF c=7 THEN b$=" "
IF c=6 THEN b$=" * "
IF c=5 THEN b$=" * "
IF c=4 THEN b$=" * * * "
IF c=3 THEN b$=" * "
IF c=2 THEN b$=" * "
IF c=1 THEN b$=" "
PRINT RIGHT$(a$,c)+b$+RIGHT$(a$,c)
c=c-1
WEND
```

My program's output:

******* *******

****** * ******

***** * *****

**** * * * ****

*** * ***

** * **

* *

Sorry, but I don't understand that expression...too advanced for me.

What does your method suggest is the pattern for this sequence?

Hi Alg Num Theory;

Well, that solution certainly wasn't staring me in the face!

I haven't got the first clue as to what it is or does or how it works, though, as it seems to be way beyond my low maths level (unless I've forgotten it from school).

I'll have to take your word for it that it's a solution.

*EDIT: I entered it into W|A, which gave results (including this puzzle's solution) for the first 15 integer values of n. *

Here's my spreadsheet solution. I started writing it all out longhand but got rather tongue-tied, and decided to just go with the simpler presentation.

You'll see that I had to dig down pretty deep to get the answer.

The solution relies on the hidden pattern of fractions mentioned in my previous post:

"... a sequence of fractions, in which:

- the denominator is 1 greater than the numerator; and

- the denominator and numerator are positive integers that are either both 1 greater than, or both 1 less than, the respective elements of adjacent fractions."

No doubt there's a solution much closer to the surface that is simply staring me in the face, but which I'm blind to!

Ah, yes...I finally got 20!

Without spoiling all the fun and giving the game away entirely, I'll just say (for now at least) that I saw a hidden pattern of a sequence of fractions, in which:

- the denominator is 1 greater than the numerator; and

- the denominator and numerator are positive integers that are either both 1 greater than, or both 1 less than, the respective elements of adjacent fractions.

Hi;

I got 18, like so:

Btw, that method gives the next number below 18 as being 16, which seems to be the lowest integer solution and is not a multiple of 6.

I haven't been able to find a method that would get the answer 20.

FWIW, to find the next number above 1296, I used a similar strategy to the one I used above and got 23328, like so:

Hi JohnOfStony,

I only found 13 solutions to your alternative puzzle.

A unique solution exists with the constraint, "The value of the sum's first letter ('D') is a prime number".

Another alternative puzzle, ALPHA - BETA - GAMMA = DELTA, has 4 solutions. A unique solution exists with the constraint, "The value of the sum's first letter ('D') is an odd prime number".

Hi Liaminati4444;

Sorry, we had to add 99 to the post before. It was actually 196,713.

But you didn't add 99 to the post before, either. ( ͡° ͜ʖ ͡°)

Your number should have been 196,812, except that Agnishom in post #1987 missed posting his number, too (he was missing bobbym, so I understand).

Catchup: 196,911.

Mine: 197,010.

Each posted number should be 99 x the post number.

Zeeshan 01 wrote:

Can you show me how to solve??

Did you look at the page I gave the link to?

Although it is headed 'Percentage Change', the first part of it covers your problem completely, by giving:

1. the definition of *percentage increase*;

2. two different methods of calculating *percentage increase*;

3. one calculation example for each of the two methods.

MathsIsFun's treatment of this topic is excellent and very clear.

Thanks, Samuel, but thickhead's one, not me. I had to take the non-maths route.

I got Mathematica to work out the permutations and export them to a text file, and then copied the contents into Excel which counted the number of valid seating arrangements.

Mathematica could have done that last bit too, but I didn't know how. If bobbym was still here I'd've asked him, and he would've taught me how immediately!

Mathematica code: Export["seating.txt", Permutations[{c,c,c,c,c,r,r,r,r,r,m,m,m,m,m},{15}]]

Excel:

- Pasted the permutions list from the text file into A1, which Excel automatically populated into A1:A756756.

- Entered this formula into B1: =IF(AND(MID(A1,2,1)<>"c",MID(A1,5,1)<>"c",MID(A1,8,1)<>"c",MID(A1,11,1)<>"c",MID(A1,14,1)<>"c",MID(A1,17,1)<>"r",MID(A1,20,1)<>"r",MID(A1,23,1)<>"r",MID(A1,26,1)<>"r",MID(A1,29,1)<>"r",MID(A1,32,1)<>"m",MID(A1,35,1)<>"m",MID(A1,38,1)<>"m",MID(A1,41,1)<>"m",MID(A1,44,1)<>"m"),1,"")

- Double-clicked on the copy handle to automatically copy the formula down Column B alongside all the permutations in Column A.

- Entered this formula into C1: =SUM(B:B)

C1 output = 2252.

All quite quick, now that you clarified the problem, which shrank it to a manageable size for my method.

*EDIT: This Mathematica code will give the answer 2252 (a post on mathematica.stackexchange gave me a clue):*

`Length[DeleteCases[Permutations[{c,c,c,c,c,r,r,r,r,r,m,m,m,m,m},{15}],{___,c,___,_,_,_,_,_,_,_,_,_,_}|{_,_,_,_,_,___,r,___,_,_,_,_,_}|{_,_,_,_,_,_,_,_,_,_,___,m,___}]]`

It can be run online at Wolfram Programming Lab, if you don't have Mathematica. Just paste my code over the "2+2" code that appears in program 1 on the opening page, then press the orange/white 'Run input' arrow (or click somewhere in the code and press Shift+Enter).

Hi;

756756 permutations - 754504 constraints = 2252 different ways.

Hi Samuel;

I'd say, from the figures that are still embedded indelibly in my brain after spending so much time on your problem, that 2252 is a fair bit short of the mark.

Your puzzle, without any 'who can't sit where' constraints, has (3x5)! - ie, 1,307,674,368,000 - permutations of different seating arrangements.

Reducing the numbers in each group, I get:

(3 groups of 2)! = 720 different arrangements, of which 640 are eliminated by the seating constraint, leaving 80 valid arrangements;

(3 groups of 3)! = 362880 different arrangements, of which 350784 are eliminated by the seating constraint, leaving 12096 valid arrangements.

I got Mathematica to print the permutations, which I pasted into a text editor and did the eliminations there.

The next reduced group, that of 3 groups of 4 people, would give an even larger number of valid arrangements, and your 3 groups of 5 people puzzle would result in something much larger than the 3x4...which thickhead has probably found (not that I can confirm it).

Hi thickhead;

I've actually spent quite some hours on this, but I just don't have enough knowledge or understanding in this area to get anywhere with it. Having quit school after flunking 4th-year high school makes it well-nigh impossible for me to tackle something like this mathematically...which a problem of this size really needs.

Anyway, I ignored that and tried to solve it by reducing the OP's 5x3 group to the groups 2x3, 3x3 and 4x3, got each of the 3 groups' permutations, sifted out their incorrect seatings and obtained solutions for those groups (the 4x3 took a lot of effort!!). My plan was to play 'spot the pattern' with that info, but despite seeing lots of factorial content I just couldn't see a common factorial (or other) pattern in those groups that I could use to solve the 5x3 group.

I eventually decided that I'd spent far too much time taking the long route to nowhere, and gave up...and to make sure I didn't return to it (I find it hard to give up on something that I think I have a chance of solving, mind you!), I threw all of my work away.

Sorry, but your solution goes waaay over my head, and so I didn't comment.

Hi Zeeshan 01;

Zeeshan 01 wrote:

Aslam's weekly salary increased from rs 175 to rs 201.25 find percentage of increase??

15 percent

25 percent

5 percent

The following MIF page is a good one to help you with that: Percentage Change.

This next code takes only about one 50th of the time of the previous post's code, achieved by changing the method by which the results are printed.

Instead of printing them in 'output format' within Mathematica (which takes forever), this code prints them in text format to a file that I called "list.txt", which M automatically places into my Windows 10 'Documents' folder.

The file contents then print into M's output pane...in a blink!

The contents of the file are automatically overwritten each time the program is run, but renaming the file in the code before an evaluation will create a separate file. That only needs to be done in one location...the 'f' variable in the first line.

The results are listed in descending numerical order within each group of deducted primes - as per the OP's method - and those deducted prime groups appear in ascending order of deducted primes (see example in the hide box in the previous post).

I've included a counter that returns the total number of odd-prime trios.

The next code displays the results in ascending order:

These codes also work in the online Wolfram Programming Lab (although the output is limited to 150 lines), but not in the Mathics link that worked on my earlier code versions.

This code is nearly twice as fast as the one in my previous post.

It now counts +/- 2 instead of 1 and starts the count from an odd number, thus having to test only odd numbers for primality.

The output is for sum = 31.

The following Mathematica codes display all possible trios of odd primes for a given sum (which must be odd).

For Mathematica program, or online at Wolfram Programming Lab:

Online at Mathics, here:

You'll run into time/memory problems pretty quickly because of the exponential growth in permutation numbers. Wolfram is much quicker than Mathics and handles larger numbers better, giving the answers to sum = 1001 immediately, while Mathics times out. Wolfram failed with sum = 10001.

Hi!

Thought I'd try this on a spreadsheet (Excel)...so here is a link to a video of it in action. It basically follows the M-code method from my previous post.

I don't know any VBA, hence the spreadsheet approach...with iterations, Conditional Formatting, and a couple of macros assigned to rectangle shapes.

Enjoy the accompanying music clip! It's called *Jazz in Paris*.

I think you'll like it (the music, I mean).

If you have Mathematica, here is some code you could run that will give a range of answers depending on your input:

The program will ask you to enter:

1. the sum of 3 odd primes (which must be an odd number); and

2. the deducted (non-paired) prime.*Note: An incorrect answer to a question will result in the question being repeated. *

For sum = 31 and deducted prime = 5, the output is:

5 + 13 + 13 = 31

5 + 7 + 19 = 31

5 + 3 + 23 = 31

For sum = 31 and deducted prime = 7, the output is:

7 + 11 + 13 = 31

7 + 7 + 17 = 31

7 + 5 + 19 = 31

------------------------------------------------------------------------------------------------------

If you don't have Mathematica, here are two online options for running Mathematica code:

1. The new, free, cloud app Wolfram Programming Lab. Session times are quite short, but you can refresh, although you may need to paste the code again. Also, being a new app, it's a bit slow and unresponsive at times, and so you may need to be patient, or even to run the code again.

(a) Paste my code (above) over the '2+2' that appears in the first program, left-click anywhere in the pasted code, and press Shift+Enter to run.

(b) Enter the requested values into the popup windows, making sure to click 'OK' (not the 'Enter' key) when you've finished typing.

2. Mathics Online. There doesn't seem to be a session time limit.

(a) Paste the following code onto the page at the blinking cursor, and change the first line's pre-entered 'x' and 'a' values to suit.

(b) Left-click anywhere in the pasted code, and press Shift+Enter to run.

* There doesn't seem to be an Input-with-prompt function (unlike with Wolfram Programming Lab), but just change the 'x' and 'a' values directly in the code.*

Hi rushatiindia,

I would like to know how to calculate and express a number as the sum of three odd primes.

I can't think of a simple way of doing that, as the contents of groups of three primes are too inconsistently spaced.

The best idea I can come up with to calculate groups of three odd primes that will total a given sum is to deduct an odd prime from the sum, and then to find the remaining prime-pair by your +/- method (but I don't know how to put that into a single expression).

eg, for sum = 31 and deducted prime = 11:

31 - 11 = 20

20/2 = 10

10 - 1 = 9 and 10 + 1 = 11: False (9 isn't a prime)

10 - 2 = 8 and 10 + 2 = 12: False (8 and 12 aren't primes)

10 - 3 = 7 and 10 + 3 = 13: True (7 and 13 are primes)

That gives the answer 11 + 7 + 13 = 31.

There are 5 other answers for 31, comprising the deducted prime followed by a prime-pair that is found by your +/- method:

a) 3 + 11 + 17 = 31

b) 3 + 5 + 23 = 31

c) 5 + 13 + 13 = 31

d) 5 + 7 + 19 = 31

e) 7 + 7 + 17 = 31

Some questions:

1. Are all five of my answers valid for your purposes?

2. What is the highest sum you want this for?

3. Are duplicate primes allowed? eg, as in 7 + 7 + 17 = 31.

4. Does the fact that the sum of 3 odd primes is *always* an odd number lead to any problems?

5. How do you determine primality? eg, from a list of primes.

6. Is one answer better than another? eg, is 7 + 11 + 13 = 31 better than 3 + 5 + 23 = 31?

7. How do we choose the deducted prime? eg, the next prime higher than sum/3. The choice will determine the range of answers.

8. Do you want to do this just by hand/calculator/primes list?

(a) If not, do you have access to Mathematica? (see next post)