## Problem 684

A place to air possible concerns or difficulties in understanding ProjectEuler problems. This forum is not meant to publish solutions. This forum is NOT meant to discuss solution methods or giving hints how a problem can be solved.
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.

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 post any spoilers
Kenya_A
Posts: 3
Joined: Sat Dec 12, 2015 4:09 am

### Problem 684

Problem 684 (View Problem)
Hi,
I haven't solved this yet, but I noticed that the example number has the same quotient and remainder when divisible by 9, so it's impossible to tell using it alone if you have made a mistake in entering one of these into the solution.

I can't solve it because, try I might, I haven't found enough tricks to calculating the numbers in a reasonable time and without overflow. I have done modulo operations after each addition and multiplication, tried (and abandoned in favour of built-ins) a method of modular exponentiation which cancels out much of the multiplying by setting the relevant exponents mod x to 1, and found closed form expressions for the sums. The limit is the exponentiations. What, besides maybe the F's thm, can speed this up? It may be finished yet by this time next year at this rate.

835410_BD2wXg2iurN8FEuwdp659qnINUNqNKbA
hk
Posts: 11286
Joined: Sun Mar 26, 2006 10:34 am
Location: Haren, Netherlands

### Re: Problem 684

In the big pink box at the top of the page it reads:

'Don't ask for hints how to solve a problem'
nicolas.patrois
Posts: 118
Joined: Fri Jul 26, 2013 4:54 pm
Contact:

### Re: Problem 684

Hi,
Is sum from i=2 to i=30 S(fi) (mod 1_000_000_007) equal to xxxxxxxxx? <value snipped by moderator>
Thank you.
RudiGj
Posts: 1
Joined: Fri Jan 03, 2020 11:59 pm

### Re: Problem 684

Just need a little bit of clarification on this problem.

Do you have to find the smallest digit sum for each term of the fibonacci sequence from the 2nd to the 90th?

digitsum(1) + digitsum(2) + digitsum(3) + digitsum(5) + digitsum(8) + .... + digitsum(n) until the 90th term?
RobertStanforth
Posts: 1639
Joined: Mon Dec 30, 2013 11:25 pm

### Re: Problem 684

RudiGj wrote: Sat Jan 04, 2020 12:04 am Do you have to find the smallest digit sum for each term of the fibonacci sequence from the 2nd to the 90th?
No, that is not correct. $S(n)$ is not digitsum.
Instead, $s(n)$ is the inverse digit sum, so $\mathrm{digitsum}(s(n)) = n$.
Note also that $S$ is the sum of $s$.

So, (given a Fibonacci number $f_i$), you have to find the smallest number whose digit sum is $n$, for each number $n$ up to $f_i$. Their sum gives you $S(f_i)$.
Then the answer would be: $S(1) + S(2) + S(3) + S(5) + S(8) + ... + S(f_{90})$.
AWR
Posts: 2
Joined: Mon Apr 13, 2020 12:59 pm

### Re: Problem 684

Just solved this after quite a bit of head scratching.

Seems a bit hard for a Difficulty rating of 5%?
Or maybe I'm just a bit thick?

Andrew
hk
Posts: 11286
Joined: Sun Mar 26, 2006 10:34 am
Location: Haren, Netherlands

### Re: Problem 684

Please have a look at the fastest solvers table....
AWR
Posts: 2
Joined: Mon Apr 13, 2020 12:59 pm

### Re: Problem 684

hk wrote: Mon Apr 13, 2020 1:13 pm Please have a look at the fastest solvers table....
True, there are some quick solutions but they all revolve around figuring out the mathematics. Once done the coding is simple. How do you balance mathematical know-how against coding ability? Problem 243 was similar - it was easy if you got your head around the maths. (I was much more familiar with the mathematics required for that problem!)

I still wouldn't put this problem in the same category with problems 53 and 55 for example!
hk
Posts: 11286
Joined: Sun Mar 26, 2006 10:34 am
Location: Haren, Netherlands

### Re: Problem 684

The simple answer is: the difficulty assessment is automatically calculated based on solver times.
We've no better way to do it..
yourmaths
Posts: 31
Joined: Mon Aug 25, 2014 11:00 am

### Re: Problem 684

I have what I think is a correct algorithm for this problem but my answer is not being accepted.
RobertStanforth wrote: Sat Jan 04, 2020 9:04 am So, (given a Fibonacci number $f_i$), you have to find the smallest number whose digit sum is $n$, for each number $n$ up to $f_i$. Their sum gives you $S(f_i)$.
Then the answer would be: $S(1) + S(2) + S(3) + S(5) + S(8) + ... + S(f_{90})$.
Is this right? From the problem description the answer should be given by
$S(f_2) + S(f_3) + ... + S(f_{90})$
level = lambda number_solved: number_solved // 25
Animus
Posts: 1926
Joined: Sat Aug 16, 2014 1:23 pm

### Re: Problem 684

The Fibonacci sequence is given as $f_0=0, f_1=1, f_2=1, f_3=2 \dots$
yourmaths
Posts: 31
Joined: Mon Aug 25, 2014 11:00 am

### Re: Problem 684

All good. I had a frustratingly hard-to-find typo.
level = lambda number_solved: number_solved // 25
codingclubwaseesucks
Posts: 1
Joined: Sat Jul 04, 2020 6:50 pm

### Re: Problem 684

Could you clarify what you mean about "Instead, s(n) is the inverse digit sum, so digitsum(s(n))=n"?
What is an Inverse Digit Sum?
RobertStanforth wrote: Sat Jan 04, 2020 9:04 am
RudiGj wrote: Sat Jan 04, 2020 12:04 am Do you have to find the smallest digit sum for each term of the fibonacci sequence from the 2nd to the 90th?
No, that is not correct. $S(n)$ is not digitsum.
Instead, $s(n)$ is the inverse digit sum, so $\mathrm{digitsum}(s(n)) = n$.
Note also that $S$ is the sum of $s$.

So, (given a Fibonacci number $f_i$), you have to find the smallest number whose digit sum is $n$, for each number $n$ up to $f_i$. Their sum gives you $S(f_i)$.
Then the answer would be: $S(1) + S(2) + S(3) + S(5) + S(8) + ... + S(f_{90})$.
dawghaus4
Posts: 56
Joined: Fri Nov 29, 2013 2:22 am

### Re: Problem 684

codingclubwaseesucks wrote: Sat Jul 04, 2020 6:51 pm Could you clarify what you mean about "Instead, s(n) is the inverse digit sum, so digitsum(s(n))=n"?
What is an Inverse Digit Sum?
Let digitsum(x) be the sum of the digits of the number x. For example, digitsum(19) = 10. An inverse function would reverse that. If the sum of the digits is 10, what is the number. Without the restriction, "the smallest number," there would be lots answers With the restriction, we can say 19 is the smallest number with a digit sum of 10. That is what is meant by an Inverse Digit Sum.

In the problem, n is the digit sum, and s(n) is the smallest number whose digits sum to n. digitsum(19) = 10 and s(10) = 19.

Hope that helps.
PurpleBlu3s
Posts: 75
Joined: Mon Sep 19, 2011 6:49 pm

### Re: Problem 684

Generalise the problem such that F(N) = S(f2) + ... + S(fN).

I have a (slow) brute force algorithm, a medium algorithm and a fast algorithm. They all agree as far as I can push the slower ones, which is up to F(22) for the brute force and F(46) for the medium algorithm.

The brute force and medium algorithm both agree with S(20) = 1074 (the fast one only works on Fibonacci inputs).

My answer for F(90) is apparently not correct.

Is anyone willing to verify a couple of intermediate results?
gaufowl
Posts: 5
Joined: Tue Sep 22, 2020 10:36 pm
Location: MD,USA

### Re: Problem 684

PurpleBlu3s wrote: Thu Dec 31, 2020 6:15 pm Is anyone willing to verify a couple of intermediate results?
I'd be willing to do some cross verification with you. I haven't solved it yet either but I believe I have it running correctly so far up to the mid-30 of fibonacci numbers. Feel free to pm me on here.

1691991_rIEOKCNEDBtm7EzRUeWtIZDvhFNxQVp1
pjt33
Posts: 70
Joined: Mon Oct 06, 2008 6:14 pm

### Re: Problem 684

PurpleBlu3s wrote: Thu Dec 31, 2020 6:15 pm The brute force and medium algorithm both agree with S(20) = 1074 (the fast one only works on Fibonacci inputs).
I think it's a legitimate hint to say that there's nothing special about Fibonacci inputs. My best guess is that the question asks for the particular Fibonacci-based sum that it does as a way of making the calculation expensive enough to trip up brute force solutions without using inputs that don't fit in a 64-bit integer.