Math Is Fun Forum

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

You are not logged in.

#1 Re: Computer Math » Project Euler Problems 4-6 » 2024-05-17 21:45:54

Keep_Relentless wrote:

Problem 6 looked really easy so I solved it first.

Yes, that fell into place quite quickly in Excel.

M took me a bit longer to suss out...even though the code looks pretty simple.

#2 Re: Computer Math » Project Euler Problems 4-6 » 2024-05-17 21:06:52

Keep_Relentless wrote:

I did problem 5 with Excel too

Edit: Problem 4 as well.

I couldn't think of an easy enough way in Excel, so went with M:

#3 Re: Computer Math » Project Euler Problems 1-3 » 2024-05-17 18:41:54

Keep_Relentless wrote:

I did problem 2 on Excel too, manually. There are only 32 terms of that Fibonacci sequence less than four million.

Yes, I solved it with Excel...and just now in M.

#4 Re: Computer Math » Project Euler Problems 4-6 » 2024-05-17 16:19:50

Keep_Relentless wrote:

By the way the website asks you not to post the answers.

I'd overlooked what you said there. I haven't posted any answers as such, just code...but running the codes will give the answers.

Shall I continue posting the way I have, or change somehow?

From their website:
"Who are the problems aimed at?
The intended audience include students for whom the basic curriculum is not feeding their hunger to learn, adults whose background was not primarily mathematics but had an interest in things mathematical, and professionals who want to keep their problem solving and mathematics on the cutting edge."

I fit into the italicised category. smile

#5 Re: Computer Math » Project Euler Problems 7-9 » 2024-05-17 13:43:56

phrontister wrote:
Keep_Relentless wrote:

A way to do problem 8 occurred to me. Let's give it a go.

Edit: Problem 8 done. Still no coding used.

Here's what I did:

This morning I worked out an M solution:

#6 Re: Computer Math » Project Euler Problems 1-3 » 2024-05-17 01:41:38

Keep_Relentless wrote:

I did problem 1 on Excel....So ideally this question should be answered by programming.

I coded it up in LibertyBASIC (it'll run in the freeware Just BASIC too):

No clever maths, just loops...which is all I can manage this time of night!

#7 Re: Computer Math » Project Euler Problems 10-12 » 2024-05-17 00:44:31

Keep_Relentless wrote:

Problem 11 could be done on Excel but I think it would take annoyingly long if I'm not missing something. I'm going to go ahead and guess that it's the diagonal 89 * 94 * 97 * 87.

That's what I got, using Excel.

Copy/paste into Excel via the Wizard refused to work, but first pasting into Notepad++ and then copy/paste from there woke the Wizard up, and the grid copied over properly with the numbers in their respective cells.

That helped greatly with finding the solution via formulas that I could copy/drag with the fill handle.

#8 Re: Computer Math » Project Euler Problems 10-12 » 2024-05-16 23:14:43

Keep_Relentless wrote:

Problem 12 done with Mathematica. Would be very surprised if it could be done with Excel.

Yes, I'd also be very surprised, given the huge numbers. But maybe an Excel whizz could...

I also solved it with M.

Verified the solution in Excel via a UDF that gave all the divisors, and a formula that counted the number of divisors. Both helps were found on the net. Also, I needed the triangular number from the M solution because of the huge numbers.

#9 Re: Computer Math » Project Euler Problems 10-12 » 2024-05-16 21:27:11

Keep_Relentless wrote:

10. The sum of the primes below 10 is 2 + 3 + 5 + 7 = 17. Find the sum of all the primes below two million.

Problem 10 done on Mathematica.

Found quite a neat 1-liner (with 4 functions) solution in M. Verified the solution in Excel.

#10 Re: Computer Math » Project Euler Problems 7-9 » 2024-05-16 01:55:00

Keep_Relentless wrote:

I got problem 9 with a mixture of Mathematica and Excel.

In case there's a way of explaining what M spit out regarding problem 9, I will share its result:

Your 500(2-√2)<b<500 is close to what I did, but I don't understand the other two. Sorry.

But here's how I solved it in M:


I didn't reinvent the wheel there...just used my BASIC strategy, which was my first solution method.

And here's my BASIC code:


Coded in Liberty BASIC, but also runs in Just BASIC (junior freeware version of LB).

I also worked out a not-too-tedious Excel solution (it looks more laborious than it is):   


I hope those Excel instructions work for you! smile

#11 Re: Computer Math » Project Euler Problems 7-9 » 2024-05-16 00:05:04

Keep_Relentless wrote:

Is it considered cheating if you use Mathematica?

I hope not, coz I've used it on a couple of Project Euler problems posted years earlier here on MIF...and I didn't give it a moment's thought then!

However, it did cross my mind that M's 'Prime[10001]' solution was borderline cheating! big_smile

By this criterion, if I understand the sieve of eratosthenes, to cross out the multiples of every prime, I have a (laborious) method I could potentially carry out on pen and paper. So it is not really a mystery how the computer arrives at the answer.

Agreed. up

Here's my clunky SofE code:

This is the Liberty BASIC code I referred to in post #8. LB costs $$, but the code also runs in Just BASIC v2.0, which is a scaled-down freeware version of LB.

I said previously that the code's 'clunky'. That was because I couldn't work out how to terminate iterations at the 10001st prime, and instead chose 'size=52370', which gives the solution that M gave! Btw, 52370*2 + 3 = that solution! dizzy

Edit: I forgot to say that the code will give just the 10001st prime. If you also want to print all the primes (which greatly slows down the operation), delete the 'Rem' tick preceding the two PRINT statements that have them, and place a Rem tick in front of the last PRINT statement.

#12 Re: Computer Math » Project Euler Problems 7-9 » 2024-05-15 10:47:54

Keep_Relentless wrote:

7. By listing the first six prime numbers: 2, 3, 5, 7, 11, and 13, we can see that the 6th prime is 13. What is the 10001st prime number? [Without looking it up.]

The Excel solution I mentioned in post #5 is a single column one that lists all the primes to the 10001st.

Mathematica has a 1-word function for returning just the 10001st prime.

My Liberty BASIC program came with a 'Sieve of Eratosthenes' module, which I adapted (clunkily) to return these options:
   (a) just the 10001st prime, or
   (b) all primes up to and including the 10001st.

#13 Re: Computer Math » Project Euler Problems 7-9 » 2024-05-15 01:31:38

Keep_Relentless wrote:

These ones are trickier. It might be time to actually start coding.

I agree...and I solved #9 with a small BASIC code a couple of minutes ago. smile

#14 Re: Computer Math » Project Euler Problems 7-9 » 2024-05-14 01:14:41

Hi Keep_Relentless;

I did #7 on Excel spreadsheet, but, after failing to come up with anything myself, cheated by using a UDF I found on the net that helped (but I won't reveal what/how, yet). smile

#15 Re: Computer Math » Project Euler Problems 7-9 » 2024-05-14 00:59:08

Keep_Relentless wrote:

A way to do problem 8 occurred to me. Let's give it a go.

Edit: Problem 8 done. Still no coding used.

Here's what I did:

#16 Re: Computer Math » Project Euler Problems 4-6 » 2024-05-13 23:57:43

Hi Keep_Relentless;

Sorry...I wasn't thinking and replied in the 1-3 thread instead of here. So here's what we said over there:

phrontister wrote:
Keep_Relentless wrote:

I found problem 5 to be the hardest to do on Excel.

I just used a calculator for #5 (product of all primes 2 to 19, multiplied by 2³ and 3 for the missing 4, 8, 9, 16 & 20). That could also be done in Excel somehow.

Keep_Relentless wrote:

Wow, you just used a calculator for #5? I made columns checking divisibility by every number up to 20 and searched for a good while. Found 46512 is divisible by 16-19, checked its multiples. Found a multiple divisible by every number 1-20 except for 11. Found the smallest one that fits 11 too.

But it was not as quick and easy as using a calculator!

I don't really know what I'm doing, but I made it this far. smile

And you had much more fun! big_smile

I went the LCM route...

#17 Re: Computer Math » Project Euler Problems 1-3 » 2024-05-13 17:43:47

Keep_Relentless wrote:

I found problem 5 to be the hardest to do on Excel. Not sure problems 7-9 can be done on Excel. 9, maybe.

I just used a calculator for #5 (product of all primes 2 to 19, multiplied by 2³ and 3 for the missing 4, 8, 9, 16 & 20). That could also be done in Excel somehow.

I did #8 first coz it intrigued me most. I used Excel but found it rather tricky...doubtless there's an easier method I didn't see.

I'll give the others a go later when I have some more time.

#18 Re: Computer Math » Project Euler Problems 1-3 » 2024-05-13 15:48:38

Keep_Relentless wrote:

3. The prime factors of 13195 are 5, 7, 13 and 29. What is the largest prime factor of the number 600851475143?

Hi Bob;

Bob wrote:

Using Excel I have found that the third number is divisible by 29 and 13 (but not 7 and 5 also not 13^2 nor 29^2)

Is the "third number" that you're referring to 13195?

If so, its prime factors are the "5, 7, 13 and 29" from Keep_Relentless's post: ie, 5 x 7 x 13 x 29 = 13195.

...or am I missing something there?

#19 Re: Computer Math » Project Euler Problems 1-3 » 2024-05-13 14:01:46

Hi Keep_Relentless;

Keep_Relentless wrote:

For problem 3,

600851475143 is not divisible by 13 or 29. Looks like Excel has rounding errors.

In fact, seems there are no prime factors below 71.

I may not be understanding what you're trying there...

My Excel found 4 prime factors (the largest being a 4-digit number), and had no rounding errors.

I used a spreadsheet, with 600851475143 in A1 and my main formula in A2, which I dragged down column A quite a way, given the large task ahead.

Each time the formula found a prime factor, the prime factor divided into the dividend and the calculation continued down the column with the resulting quotient until the next prime number was found...etc, repeating the process all the way to the end.

I'm sure that a UDF would have done a quicker & tidier job, but I'd still be coding into tonight! That is, if I could manage that at all! dizzy

#20 Re: Help Me ! » Fraction 2/3 Equals 0.666? » 2024-05-13 01:08:08

Hi Bob;

Bob wrote:

When I first joined the forum a command square brackets code could surround the math commands to stop the interpreter activating the commands. This allowed a poster to show a Latex command without it actually happening. All I see now is a black rectangle.  I'll give you an example:

What do others see?

When I'm logged in I get this:
U0xPYxZ.png
And when I'm logged out I get this:
sW4HnfG.png

I get the same effect on the 'LaTeX - A Crash Course' pages here and here.

As there's no mention in the LaTeX thread back then of there being black text on black background, I suspect that the problem is newish.

#21 Re: Help Me ! » Find Time » 2024-05-06 13:54:25

Hi Bob;

Bob wrote:

...pm is an abbreviation of the Latin phrase post meridian. Meridian is the Latin for noon so post meridian means after-noon...

Down here in Australia I learnt to use the Latin meridiem, not meridian, with the latter being more commonly a geographical term probably derived from the French méridien. See here: Grammarphobia: Ante meridiem or antemeridian?

Bob wrote:

12 hours after the meridian means midnight! I was staying at a hotel that said the fire alarm was to be tested at 12pm. Did they really mean midnight? I think a lot of guests would not be happy to have the alarm go off then.  smile

So, personally, I only use noon and midnight and shun this stupid habit of saying 12pm

This is from Wikipedia's '12-hour clock' article, about halfway down the page under the heading 'Confusion at noon and midnight':
     "It is not always clear what times "12:00 a.m." and "12:00 p.m." denote. From the Latin words meridies (midday), ante (before) and post (after), the term ante meridiem (a.m.) means before midday and post meridiem (p.m.) means after midday. Since "noon" (midday, meridies (m.)) is neither before nor after itself, the terms a.m. and p.m. do not apply." big_smile

#22 Re: This is Cool » Fermats Last Theorem Demonstration! by, Anthony.R.Brown (1998 Solved ) » 2024-05-05 09:33:45

phrontister (post #59) wrote:
phrontister (post #52) wrote:

The rounding that occurs once QB64's double-precision limit is reached has enabled me to manufacture the following X³ + Y³ = Z³ 'solution'...

I've explored that further, and found that manufacturing X³ + Y³ = Z³ 'solutions' for ARB's QB64 program is fairly easily done...like so:
   1. X¹ = a 17-digit number.
   2. Y¹ = X¹.
       Note: {Y¹ = X¹+1}, {Y¹ = X¹+2} and {Y¹ = X¹+3} also work well, but yield successively fewer 'solutions' than {Y¹ = X¹}.
   3. Z¹ = the cube root of Z³: just select the first 17 digits of the cube root (the last digit may need rounding up if it's ≥5).

Inspired by the second image in my post #52, my theory was that for both X¹ & Y¹ >17 digits, there'd be 'solutions' if their lengths are equal and their first 17 digits are equal (or nearly equal). However:
   1. My first trial, with X¹ & Y¹ both 24 digits long, resulted in no solutions until their first 19 digits were equal...got the "WOW!" output then. up
   2. My next trial, with X¹ & Y¹ both 30 digits long, resulted in no solutions (tried equal digits from first 15 to first 30, all in vain). Hmm...

Conclusion: There are many, many 'solutions', but I haven't found the 'rule' that discovers them all.

#23 Re: This is Cool » Fermats Last Theorem Demonstration! by, Anthony.R.Brown (1998 Solved ) » 2024-04-27 00:27:53

phrontister (post #52) wrote:

The rounding that occurs once QB64's double-precision limit is reached has enabled me to manufacture the following X³ + Y³ = Z³ 'solution'...

I've explored that further, and found that manufacturing X³ + Y³ = Z³ 'solutions' for ARB's QB64 program is fairly easily done...like so:
   1. X¹ = a 17-digit number.
   2. Y¹ = X¹.
       Note: {Y¹ = X¹+1}, {Y¹ = X¹+2} and {Y¹ = X¹+3} also work well, but yield successively fewer 'solutions' than {Y¹ = X¹}.
   3. Z¹ = the cube root of Z³: just select the first 17 digits of the cube root (the last digit may need rounding up if it's ≥5).
   
Using ARB's latest code (post #33), I added an option to enter custom X¹,Y¹,Z¹ numbers instead of using the program's random numbers. Here's my adapted code:

I ran that code a few minutes ago, and here's an image from it:

DRatIFl.png

In my adapted code I restricted the length of the random numbers so that their cubes display accurately, with no rounding or truncation: ie, within QB64 double-precision limits.

#25 Re: This is Cool » Fermats Last Theorem Demonstration! by, Anthony.R.Brown (1998 Solved ) » 2024-04-23 21:12:27

AnthonyRBrown wrote:

Most people read all the threads,and then walk away! sad

But I'm still here! big_smile

Board footer

Powered by FluxBB