Computer Science, asked by mateensah1009, 10 months ago

accept a number n upto 5 digits long in the positional numeral system formed by symbols 0,1,.....9,a,.....,z.also ,accept another symbol s other than zero.considering n to be represented in the least base possible between 2 and 36 ,identify the smallest prime number greater than n that contains at least one occurance of s in it in base s+1.

Answers

Answered by sourasghotekar123
0

Answer:

a common prime number. Constraints Size of N Basis value 10 0 => 0 1 => 1 2 => 2 …. 9 => 9 A => 10 B => 11 …. Z => 35 Input Format two integers, N and S, separated by a space, on a single line. Output Print the smallest prime number in base S + 1 that is bigger than or equal to N and has at least one instance of S in it. Format of Output Print the smallest prime number in base S + 1 that is bigger than or equal to N and has at least one instance of S in it. Example 1 Input 10 B Output B Explanation N can have bases as low as 2, and 2 is the value of N in that base. We are searching for the smallest prime number in base 12 that is bigger than or equal to 2, contains the symbol B, and is 1 more than the face value of B, which is 11. The first three numbers with face value B in base 12 are B (value 11), 1B (value 1 * 12 + 11 = 23), and 2B (value 2 * 12 + 11 = 35). Of these, 11 is the smallest prime number and is higher than N. Therefore, B is the result. Example 2: (1 more than the face value of B, 11) that contains symbol B and is greater than or equal to 2. The first few numbers in ascending order in base 12 containing face value B are B (value 11), 1B (value 1 * 12 + 11 = 23), 2B (value 2 * 12 + 11 = 35): of these the smallest number that is prime is 11, which is greater than N. Hence, the output is B. Example 2 Input ZZ Z Output 11Z

See more:

https://brainly.in/question/23511504

#SPJ1

Similar questions