Lucas is working on a digit-based game and needs a program to count how many digits in a given number can evenly divide the number itself. Write a program to help Lucas by taking an integer as input, iterating through each digit using a for-each loop, and printing the count of digits that divide the number evenly.Input format :The input consists of a single integer n.Output format :The output prints the count of digits in n that divide the number evenly.Refer to the sample output for formatting specifications.Code constraints :1 ≤ n ≤ 107Sample test cases :Input 1 :124Output 1 :3Input 2 :573Output 2 :1
Question
Lucas is working on a digit-based game and needs a program to count how many digits in a given number can evenly divide the number itself. Write a program to help Lucas by taking an integer as input, iterating through each digit using a for-each loop, and printing the count of digits that divide the number evenly.Input format :The input consists of a single integer n.Output format :The output prints the count of digits in n that divide the number evenly.Refer to the sample output for formatting specifications.Code constraints :1 ≤ n ≤ 107Sample test cases :Input 1 :124Output 1 :3Input 2 :573Output 2 :1
Solution
Here is a Python program that fulfills the requirements:
def count_divisible_digits(n):
count = 0
for digit in str(n):
if int(digit) != 0 and n % int(digit) == 0:
count += 1
return count
# Test cases
print(count_divisible_digits(124)) # Output
Similar Questions
Alex is teaching his younger sister how to count the number of digits in an integer. He wants to write a program that takes an integer n as input and counts the number of digits using a do-while loop. Company Tags: CapgeminiInput format :The input consists of a single integer n.Output format :The output prints a single integer representing the count of digits in the given number.Refer to the sample output for formatting specifications.Code constraints :1 ≤ n ≤ 107Sample test cases :Input 1 :1Output 1 :1Input 2 :1000Output 2 :4Input 3 :54782Output 3 :5
James, a mathematics teacher, is developing a programming exercise to help his students practice continuously summing the digits of a number until it becomes a single-digit integer. He wants to create a simple program using a 'while' loop that takes a positive integer input and generates the final single-digit result. Input format :The input consists of a positive integer n.Output format :The output prints "The single-digit sum of n is Y." where n is the input integer and Y is its single-digit sum.Refer to the sample output for formatting specifications.Code constraints :1 ≤ n ≤ 1010Sample test cases :Input 1 :456Output 1 :The single-digit sum of 456 is 6.Input 2 :999Output 2 :The single-digit sum of 999
Rohit is tasked with designing a program to analyze the digits of a given integer. Write a program to help Rohit that takes an integer as input and identifies the minimum odd digit and the maximum even digit present in the number. If no odd or even digits are present, display appropriate messages. Implement the solution using a 'while' loop to iterate through the digits of the given number.Input format :The input consists of an integer n.Output format :The first line of output prints the minimum odd digit in the given integer.If there is no odd digit, print "There are no odd digits in the number."The second line prints the maximum even digit in the given integer.If there is no even digit, print "There are no even digits in the number."Refer to the sample output for formatting specifications.Code constraints :The given test cases fall under the following constraints:1 ≤ n ≤ 107Sample test cases :Input 1 :3465Output 1 :Minimum odd digit: 3Maximum even digit: 6Input 2 :97975Output 2 :Minimum odd digit: 5There are no even digits in the number.Input 3 :24642Output 3 :There are no odd digits in the number.Maximum even digit: 6
Given a number n (greater than 9), write a code to find remainder when 'n' is divided by last two digits of n. If last two digits of the number are zero then print 'Division cannot be performed'.For example, if n is 314 then the output is 6 and when n is 12 output is 0. If n is 100 then print 'Division cannot be performed'Input FormatFirst line contains the number nOutput FormatPrint remainder of division of n by last two digits of n
You are given a number ’n’.Find the number of digits of ‘n’ that evenly divide ‘n’.
Upgrade your grade with Knowee
Get personalized homework help. Review tough concepts in more detail, or go deeper into your topic by exploring other relevant questions.