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

Home > Numbers
Lynch-Bell numbers (Posted on 2023-01-27) Difficulty: 3 of 5
L-B number is a number with distinct non-zero digits divisible by each of its digits e.g. 186432.

a. What is the largest LBN not containing the digit 1?
b. How many LBNs contain the digit 4?
c. Same for digit 5.
d. What is the largest LBN?

Provide your reasoning and/or program; solution by searching for answers on the web will be considered unfair…

See The Solution Submitted by Ady TZIDON    
Rating: 5.0000 (1 votes)

Comments: ( Back to comment list | You must be logged in to post comments.)
Solution Solution | Comment 1 of 3
The largest LBN without a 1 is 978264
The number of LBNs containing the digit 4 is 339
The number of LBNs containing the digit 5 is 12
The largest LBN is 9867312

---------------
def isLynchBell(n):
    """  Lynch-Bell numbers
    L-B number is a number with distinct non-zero digits divisible by each of its digits  """
    st = str(n)
    if '0' in st:
        return False
    if len(set(st)) != len(st):
        return False
    for c in st:
        if (n/int(c))%1 != 0:
            return False
    return True
    
lbns = [i for i in range(987654322) if isLynchBell(i)]

foundWithoutOne = False
howmanyfours = 0
howmanyfives = 0
for lbn in reversed(lbns):
    st = str(lbn)
    if not foundWithoutOne:
        if '1' not in st:
            print('The largest LBN without a 1 is', lbn)
            foundWithoutOne = True
    if '4' in st:
        howmanyfours += 1
    if '5' in st:
        howmanyfives += 1

print('The number of LBNs containing the digit 4 is', howmanyfours)
print('The number of LBNs containing the digit 5 is', howmanyfives)
print('The largest LBN is',lbns[-1])

  Posted by Larry on 2023-01-27 08:30:55
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 (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