Problem 254
Forum rules
As your posts will be visible to the general public you are requested to be thoughtful in not posting anything that might explicitly give away how to solve a particular problem.
This forum is NOT meant to discuss solution methods for a problem.
See also the topics:
Don't post any spoilers
Comments, questions and clarifications about PE problems.
As your posts will be visible to the general public you are requested to be thoughtful in not posting anything that might explicitly give away how to solve a particular problem.
This forum is NOT meant to discuss solution methods for a problem.
In particular don't post any code fragments or results.
Don't start begging others to give partial answers to problems
Don't ask for hints how to solve a problem
Don't start a new topic for a problem if there already exists one
Don't start begging others to give partial answers to problems
Don't ask for hints how to solve a problem
Don't start a new topic for a problem if there already exists one
See also the topics:
Don't post any spoilers
Comments, questions and clarifications about PE problems.
-
ukimiku
- Posts: 13
- Joined: Sun Jul 04, 2010 12:38 am
Problem 254
In Problem 254 (View Problem) the text states that g(5) was 25 and sf(25) equals 5. While I verify that sf(25) = 5,
g(5) is not 25 because 25 is not the smallest integer n that satisfies sf(n) = 5:
f(00001) = Sum of (0! + 0! + 0! + 0! + 1!) = 1 + 1 + 1 + 1 + 1 = 5
sf(00001) = Digit sum of (5) = 5
I bring this up because the idea of trailing zeroes presented itself to me while I was coming to terms with understanding the problem. Maybe it would be helpful to add to the problem description a further constraint on the positive integers in question, namely that they be written without any leading zeroes.
A very interesting and entertaining problem! Thank you.
g(5) is not 25 because 25 is not the smallest integer n that satisfies sf(n) = 5:
f(00001) = Sum of (0! + 0! + 0! + 0! + 1!) = 1 + 1 + 1 + 1 + 1 = 5
sf(00001) = Digit sum of (5) = 5
I bring this up because the idea of trailing zeroes presented itself to me while I was coming to terms with understanding the problem. Maybe it would be helpful to add to the problem description a further constraint on the positive integers in question, namely that they be written without any leading zeroes.
A very interesting and entertaining problem! Thank you.
There are two kinds of people: those who divide eyerything up into two kinds, and those who don't.
http://otac0n.com/ProjectEuler/Flair/ukimiku.png
http://otac0n.com/ProjectEuler/Flair/ukimiku.png
- Lord_Farin
- Posts: 239
- Joined: Wed Jul 01, 2009 10:43 am
- Location: Netherlands
Re: 254
In general, for PE problems the policy is that no leading zeroes are allowed, except if explicitly mentioned.ukimiku wrote:Maybe it would be helpful to add to the problem description a further constraint on the positive integers in question, namely that they be written without any leading zeroes.

-
ukimiku
- Posts: 13
- Joined: Sun Jul 04, 2010 12:38 am
Re: 254
Thanks for replying. I quite distinctly remember a couple of problems (with pandigital/palindromatic numbers, for instance) that explicitly excluded trailing zeroes in the problem statement. So it is not clear that the "general PE policy" is to forbid leading zeroes. Anyhow, a short remark in the problem statement would certainly clarify things a bit, in my opinion.
Regards,
Regards,
There are two kinds of people: those who divide eyerything up into two kinds, and those who don't.
http://otac0n.com/ProjectEuler/Flair/ukimiku.png
http://otac0n.com/ProjectEuler/Flair/ukimiku.png
-
TripleM
- Posts: 384
- Joined: Fri Sep 12, 2008 3:31 am
Re: 254
If leading 0s were allowed, the entire problem wouldn't make sense - f(n) wouldn't be well defined. If I asked you how many digits the number 342 had, I don't think many people would answer '3 or 4 or 5 or ...' or think it needed clarification 
-
eppie
- Posts: 14
- Joined: Sat Jul 02, 2011 5:19 pm
Re: Problem 254
I've been playing around with this problem, and can't see where I'm going wrong. I get g(20) is 267, and g(5) is 25, so I think I'm finding the right G(i) numbers (but not nearly fast enough for 150). However my value for ∑ sg(i) for 1 ≤ i ≤ 20 is 166 not 156 as stated in the problem.
Could someone who has solved this confirm that ∑ sg(i) for 1 ≤ i ≤ 20 is 156?
I've challenged myself to solve a problem that less than 500 people have solved for my 50th problem to get to level 2. I think I'm going to be losing sleep over this one
I just found my problem (typo on the value of 9!)
Now on to the solution.....
Could someone who has solved this confirm that ∑ sg(i) for 1 ≤ i ≤ 20 is 156?
I've challenged myself to solve a problem that less than 500 people have solved for my 50th problem to get to level 2. I think I'm going to be losing sleep over this one
I just found my problem (typo on the value of 9!)
Now on to the solution.....
-
ParadiceCity9
- Posts: 15
- Joined: Sat Dec 17, 2011 7:15 pm
- Location: Charlottesville, Virginia
Re: Problem 254
I had no trouble getting the answer for 1 <= i <= 20. However, I just tried running my program for up through 150 and it's basically freezing at 41, 45, 46, and 47, and I'm getting to numbers in the tens of millions before I find a correct value. For example, I'm getting g(45) = 12378889. Can someone verify this so I know I'm at least not doing anything incorrectly?
-
ParadiceCity9
- Posts: 15
- Joined: Sat Dec 17, 2011 7:15 pm
- Location: Charlottesville, Virginia
Re: Problem 254
I suppose that's good news. However, my code gets stuck on 47 for at least 45 minutes (I terminated it at that point). Any advice?
-
Melnofil
- Posts: 1
- Joined: Tue Sep 17, 2013 7:07 am
-
mdean
- Posts: 206
- Joined: Tue Aug 02, 2011 2:05 am
Re: Problem 254
Anyone tried taking this on with pencil and paper? It's not too bad until you get into the 30's...
I may need to think hard on a program. Or just skip it for now.
I may need to think hard on a program. Or just skip it for now.

-
hamsterofdeath
- Posts: 20
- Joined: Fri Apr 27, 2018 7:17 pm
Re: Problem 254
can this be solved without knowing a fitting theorem etc by chance?
if not, what's the topic i need to investigate?
obviously "optimized brute force" is getting me nowhere
if not, what's the topic i need to investigate?
obviously "optimized brute force" is getting me nowhere
-
h_anand
- Posts: 14
- Joined: Wed May 27, 2015 1:45 am
Re: Problem 254
Listed below are the values of g(n) and sg(n) for n in [1, 20]
Thank you,
1, 1, 1 2, 2, 2 3, 5, 5 4, 22, 4 5, 25, 7 6, 3, 3 7, 13, 4 8, 23, 5 9, 6, 6 10, 16, 7 11, 26, 8 12, 44, 8 13,144, 9 14,256,13 15, 36, 9 16,136,10 17,236,11 18, 67,13 19,167,14 20,267,15They sum up to 154 (not 156). Could anyone please point me to the wrong value(s)?
Thank you,