Some of numbers are formed with closed paths
The digits are 0,4,6qnd 9
Answers
Answered by
0
Answer:
Counting Closed Paths
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 all of its digits combined.
Example
number = 649578
The digits with closed paths are 6, 4, 9 and 8. The total number of closed paths is 1 + 1 + 1 + 2 = 5.
Function Description
Complete the function closedPaths in the editor below.
closedPaths has the following parameter(s):
int number: an integer
Returns:
int: the number of closed paths in number
Constraints
• 1 ≤ number ≤ 109
Answered by
1
Answer:
6 and 9 because these numbers formed with closed paths
Similar questions