All about flooble | fun stuff | Get a free chatterbox | Free JavaScript | Avatars    
perplexus dot info

Home > Just Math
Recursive digit transformation (Posted on 2025-03-06) Difficulty: 3 of 5
For any positive, base-10 integer N, define f(N) as the number of times you have to add up its digits until you get a one-digit number. For example, f(51) = 1 because 5+1 = 6, a one-digit number. Meanwhile, f(98) = 2, since 8+9 = 17, a two-digit number, and then adding up those digits gives you 1+7 = 8, a one-digit number.

Find the smallest whole number N such that f(N) = 4

No Solution Yet Submitted by Danish Ahmed Khan    
No Rating

Comments: ( Back to comment list | You must be logged in to post comments.)
Solution Solution | Comment 2 of 3 |
Let {a,b,c,d,e} be the smallest value of N s.t. f(N) = {1,2,3,4,5}

d is the requested value

Clearly a=1, and you can easily verify that b=19.
c is the smallest N s.t. f(N)=3 or sod(N)=19.
Since 19/9 = 2 + 1/9, c=199 since it is the smallest number for which sod()=19. Two 9s and one 1, in order from smallest to largest.

Now find d, s.t. sod(d)=199.
Since 199/9 = 22 + 1/9,d must be a 1 followed by 22 9s:
d = 19999999999999999999999 which is the requested answer.

And e, the smallest N s.t. f(N)=5 is a 1 followed by 2222222222222222222222 9s.

--------
def sod(n):
    """ Input an integer.  Returns the Sum of the Digits  """
    aList = list(str(n))
    ans = 0
    for c in aList:
        ans = ans + int(c)
    return ans

def sodCount(n):
    """ Input an integer.  Returns the number of times you have to appy the sod function to get to a single digit """
    count = 0
    m = n
    while len(str(m)) > 1:
        count += 1
        m = sod(m)
    return count

print(sodCount(19999999999999999999999))

Output:  4

  Posted by Larry on 2025-03-06 13:22:20
Please log in:
Login:
Password:
Remember me:
Sign up! | Forgot password


Search:
Search body:
Forums (0)
Newest Problems
Random Problem
FAQ | About This Site
Site Statistics
New Comments (6)
Unsolved Problems
Top Rated Problems
This month's top
Most Commented On

Chatterbox:
Copyright © 2002 - 2025 by Animus Pactum Consulting. All rights reserved. Privacy Information