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

Home > Numbers
Equal Digits Crossed Quotient Quandary (Posted on 2022-04-26) Difficulty: 3 of 5
The 4-digit positive integer 2022 has an interesting property. It has precisely three equal digits and is divisible by the sum of the digits, that is, 6.

Now the quotient obtained by dividing this number by the sum of the digits is: (2022)/6=337, which is a 3-digit number with precisely two equal digits.

Determine six positive 4-digit positive integers, each of them having the above-mentioned properties, that immediately follows 2022.

How many 4-digit positive integers (no leading zeros) with the foregoing properties precede 2022?

*** Remember: the quotient must have precisely 3 digits, exactly two of which must be equal.

See The Solution Submitted by K Sengupta    
Rating: 5.0000 (1 votes)

Comments: ( Back to comment list | You must be logged in to post comments.)
Solution Solution | Comment 2 of 3 |
There are a total of 13 such numbers, 
one is smaller than 2022 and 11 are larger.
The six that immediately follow 2022 are marked with (*)
 N  N/sod(N)
 1011 337
 2022 337
 3033 337 *
 3383 199 *
 3888 144 *
 4044 337 *
 4454 262 *
 5055 337 *
 6066 337
 7077 337
 7776 288
 8088 337
 9099 337
 Total: 13
 Before 2022: 1 
 After 2022: 11

-------------------  code -------------------
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
ct = 0
ctbefore = 0
ctafter = 0
it_is_before = True
it_is_2022 = False
it_is_after = False

for n in range(1000,10000):
    s = str(n)
    if len(set(s)) != 2:
        continue
    char = s[0]
    count = 0
    for c in s:
        if c == char:
            count += 1
    if count == 2:
        continue
    summa = sod(n)
    if n%summa != 0:
        continue
    quo = int(n/summa)
    if len(str(quo)) != 3 or len(set(str(quo))) != 2:
        continue
    print(n, int(n/summa))
    if n == 2022:
        it_is_before = False
        it_is_2022 = True
        it_is_after = True
    if it_is_before:
        ctbefore += 1
    elif it_is_after and not it_is_2022:
        ctafter += 1
    if it_is_2022:
        it_is_2022 = False
    ct += 1
print('Total:',ct)
print('Before 2022:',ctbefore, '\nAfter 2022:',ctafter)


  Posted by Larry on 2022-04-26 08:16:32
Please log in:
Login:
Password:
Remember me:
Sign up! | Forgot password


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

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