Ask Question

Some numbers are formed with closed paths. the digits 0, 4, 6 and 9 each have 1 closed path and 8 has 2. None of the other numbers is formed with a closed path. Given a number determine the total number of closed paths in each of its digits combined.

+2
Answers (1)
  1. 2 August, 05:59
    0
    def cal (n):

    s=0

    while n>0:

    r=n%10

    if (r==0 or r==4 or r==6 or r==9):

    s=s+1

    elif r==8:

    s=s+2

    n=n//10

    print (s)

    n=int (input ("enter number:"))

    print (n)

    cal (n)

    Explanation:

    Create a function to calculate count of closed path. Create a variable to store count of closed path. While number is positive, extract last digit of n. Reduce number by truncating last digit. Make a function call to compute count of path.
Know the Answer?
Not Sure About the Answer?
Find an answer to your question 👍 “Some numbers are formed with closed paths. the digits 0, 4, 6 and 9 each have 1 closed path and 8 has 2. None of the other numbers is ...” in 📗 Computers & Technology if the answers seem to be not correct or there’s no answer. Try a smart search to find answers to similar questions.
Search for Other Answers