Math Is Fun Forum

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

You are not logged in.

#1 2024-05-28 19:40:48

Keep_Relentless
Member
From: Queensland, Australia
Registered: 2024-05-05
Posts: 61

More Project Euler problems

I have not had much time recently as I've been moving, but I have scouted some of the easier problems:

Problem 16
2^15 = 32768 and the sum of its digits is 3+2+7+6+8=26. What is the sum of the digits of the number 2^1000?

Problem 20
n! means n * (n-1) * ... * 3 * 2 * 1. For example, 10! = 10*9*...*3*2*1 = 3628800, and the sum of the digits in the number 10! is 3+6+2+8+8+0+0 = 27. Find the sum of the digits in the number 100!.

Problem 25
The Fibonacci sequence is defined by the recurrence relation: Fn = Fn-1 + Fn-2, where F1 = 1 and F2 = 1. Hence the first 12 terms will be: F1=1, F2=1, F3=2, F4=3, F5=5, F6=8, F7=13, F8=21, F9=34, F10=55, F11=89, F12=144. The 12th term, F12, is the first term to contain three digits. What is the index of the first term in the Fibonacci sequence to contain 1000 digits?

Problem 40
An irrational decimal fraction is created by concatenating the positive integers: 0.123456789101112131415161718192021... It can be seen that the 12th digit of the fractional part is 1. If dn represents the nth digit of the fractional part, find the value of the following expression: d1 * d10 * d100 * d1000 * d10000 * d100000 * d1000000

Problem 45
Triangle, pentagonal, and hexagonal numbers are generated by the following formulae:
Triangle: Tn = n(n+1)/2       1,3,6,10,15,...
Pentagonal: Pn = n(3n-1)/2  1,5,12,22,35,...
Hexagonal: Hn = n(2n-1)      1,6,15,28,45,...
It can be verified that T285 = P165 = H143 = 40755. Find the next triangle number that is also pentagonal and hexagonal.

Problem 48
The series, 1^1 + 2^2 + 3^3 + ... + 10^10 = 10405071317. Find the last ten digits of the series, 1^1 + 2^2 + 3^3 + ... + 1000^1000.


"The most incomprehensible thing about the world is that it is comprehensible." -Albert Einstein.

Offline

#2 2024-05-29 02:18:08

phrontister
Real Member
From: The Land of Tomorrow
Registered: 2009-07-12
Posts: 4,860

Re: More Project Euler problems

Hi K_R;

I've done 16, 20 & 25, but that'll do me for now (bed time).

I used M for all three, with #25 taking the longest. For that one, I initially found a solution with a For loop, but then a better one with M's Fibonacci function, which I didn't know existed until it occurred to me that it might.


"The good news about computers is that they do what you tell them to do. The bad news is that they do what you tell them to do." - Ted Nelson

Offline

#3 2024-05-29 11:19:20

Keep_Relentless
Member
From: Queensland, Australia
Registered: 2024-05-05
Posts: 61

Re: More Project Euler problems

Hi phrontister;

See how long #45 takes you, I considered that a win.

To gain more proficiency I think I need to look into various ways of solving the already-done problems more efficiently


"The most incomprehensible thing about the world is that it is comprehensible." -Albert Einstein.

Offline

#4 2024-05-29 13:52:53

phrontister
Real Member
From: The Land of Tomorrow
Registered: 2009-07-12
Posts: 4,860

Re: More Project Euler problems

Haven't tried #45 yet, but succeeded with #40 after several clumsy goes at it.

Solved it in M, starting with some awful code that I didn't like, improved it a bit (still didn't like it), and eventually got something I'm quite pleased with. smile

Yes...I agree with your last comment. up

Always learning!


"The good news about computers is that they do what you tell them to do. The bad news is that they do what you tell them to do." - Ted Nelson

Offline

#5 2024-05-29 15:08:20

phrontister
Real Member
From: The Land of Tomorrow
Registered: 2009-07-12
Posts: 4,860

Re: More Project Euler problems

Keep_Relentless wrote:

See how long #45 takes you, I considered that a win.

I looked for a method in M for half an hour or so, but formed no real idea on how to go about it.

So, I opened my trusty Excel, and found the answer in about 20 minutes. smile

I'll have to try M again, though...but not sure when.

From bobbym's signature: Always satisfy the Prime Directive of getting the right answer above all else.

PS...I found a solution in M, but need to work a bit on my code still.

Last edited by phrontister (2024-05-29 17:10:22)


"The good news about computers is that they do what you tell them to do. The bad news is that they do what you tell them to do." - Ted Nelson

Offline

#6 2024-05-29 23:45:56

phrontister
Real Member
From: The Land of Tomorrow
Registered: 2009-07-12
Posts: 4,860

Re: More Project Euler problems

phrontister wrote:

PS...I found a solution in M, but need to work a bit on my code still.

I've tidied it up a fair bit, but I'm sure it can still be improved further (or changed altogether!). smile


"The good news about computers is that they do what you tell them to do. The bad news is that they do what you tell them to do." - Ted Nelson

Offline

#7 2024-05-30 01:24:22

phrontister
Real Member
From: The Land of Tomorrow
Registered: 2009-07-12
Posts: 4,860

Re: More Project Euler problems

I've solved #48 in M...a bit too big for Excel!

Not too big for my freeware Just BASIC program, though. up

That's how I first solved it in M, but later improved it to follow the more standard M way with their functions.


"The good news about computers is that they do what you tell them to do. The bad news is that they do what you tell them to do." - Ted Nelson

Offline

Board footer

Powered by FluxBB