← Complete problem index

PROJECT EULER · #0637

Flexible Digit Sum

Statement only · UnsolvedOriginal problem ↗

Given any positive integer n, we can construct a new integer by inserting plus signs between some of the digits of the base B representation of n, and then carrying out the additions.

For example, from n=12310 (n in base 10) we can construct the four base 10 integers 12310, 1+23=2410, 12+3=1510 and 1+2+3=610.

Let f(n,B) be the smallest number of steps needed to arrive at a single-digit number in base B. For example, f(7,10)=0 and f(123,10)=1.

Let g(n,B1,B2) be the sum of the positive integers i not exceeding n such that f(i,B1)=f(i,B2).

You are given g(100,10,3)=3302.

Find g(107,10,3).

Write-up coming later

The complete problem is available here. An approach, code, and answer will be added later.