Multiples of 3 containing at least one 9

21 views
Skip to first unread message

Antreas Hatzipolakis

unread,
May 4, 2026, 1:29:21 PM (10 days ago) May 4
to seq...@googlegroups.com
 

How many n-digit natural numbers contain the digit 9 at least oncε, and are also multiples of 3?

For n = 3, there are 84 numbers
(Problem by Babis Stergiou in a Greek mathematical forum)

APH
 

Dave Consiglio

unread,
May 4, 2026, 1:37:43 PM (10 days ago) May 4
to seq...@googlegroups.com
This sequence has terms:

1, 6, 84, 1056, 12504, 142536, 1582824, 17245416...


I think terms past a(0) are just A088924 / 3. 

#PYTHON
terms = []
for x in range(10):
    keep = 0
    for y in range(10**x,10**(x+1)):
        if '9' in str(y) and y % 3 == 0:
            keep += 1
    terms.append(keep)
print(keep)


--
You received this message because you are subscribed to the Google Groups "SeqFan" group.
To unsubscribe from this group and stop receiving emails from it, send an email to seqfan+un...@googlegroups.com.
To view this discussion visit https://groups.google.com/d/msgid/seqfan/CACn3DsfMsuQZ1vggjPmcOx%2By6eRJ8kRKiBaSVZ_jaFttrSKtsQ%40mail.gmail.com.

M F Hasler

unread,
May 4, 2026, 1:57:55 PM (10 days ago) May 4
to seq...@googlegroups.com
You should use range(10**k+2, 10**(k+1), 3) and omit check for divisibility. 

Also, the number of these numbers is the number of multiples of 3 with n-1 digits where you can insert (or prefix/apprend) a digit 9 anywhere. The only nontrivial thing is to avoid double counting the numbers where the 9 is inserted to the left or to the right of an existing 9.

-M.



Reply all
Reply to author
Forward
0 new messages