Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

We define 123-numbers according to the following rules. 1 is the smallest 123-number. n is a 123-number if and only if the only digits appearing

We define 123-numbers according to the following rules.

  • 1 is the smallest 123-number.
  • n is a 123-number if and only if the only digits appearing in the base-ten representation of n are the digits 1, 2, and 3, and if a digit appears, then the number of times it appears is also a 123-number.

For instance, 3 is a 123-number because it only involves the digit 3, this digit appears exactly 1 time, and we are given that 1 is a 123-number.

Knowing that 3 is a 123-number, we can now conclude that 1112 is a 123-number. 1112 contains only the digits 1 and 2. The digit 1 appears 3 times, and we know 3 is a 123-number. The digit 2 appears 1 time, and we know 1 is a 123-number.

In contrast, 2222 is not a 123-number. Although 2222 only uses the digit 2, this digit appears 4 times, and 4 is not a 123-number.

In ascending order, the first 123-numbers are: 1, 2, 3, 11, 12, 13, 21, 22, 23, 31, 32, 33, 111, 112, 113, 121, 122, 123, 131...

Write code in python to find what the 333rd and 5000th 123-number is.

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Machine Learning And Knowledge Discovery In Databases European Conference Ecml Pkdd 2022 Grenoble France September 19 23 2022 Proceedings Part 4 Lnai 13716

Authors: Massih-Reza Amini ,Stephane Canu ,Asja Fischer ,Tias Guns ,Petra Kralj Novak ,Grigorios Tsoumakas

1st Edition

3031264118, 978-3031264115

Students also viewed these Databases questions

Question

=+ 4. Why should policymakers think about incentives?

Answered: 1 week ago

Question

=+ 2. What is the opportunity cost of seeing a movie?

Answered: 1 week ago