We are given two numbers A and B. We need to calculate the number of digits after decimal. If in case the numbers are irrational then print “INF”.
Input : x = 5, y = 3 Output : INF 5/3 = 1.666.... Input : x = 3, y = 6 Output : 1 3/6 = 0.5
The idea is simple we follow school division and keep track of remainders while dividing one by one. If remainder becomes 0, we return count of digits seen after decimal. If remainder repeats, we return INF.
1 INF 1
This article is contributed by Rahul Chawla. If you like GeeksforGeeks and would like to contribute, you can also write an article using contribute.geeksforgeeks.org or mail your article to firstname.lastname@example.org. See your article appearing on the GeeksforGeeks main page and help other Geeks.
Please write comments if you find anything incorrect, or you want to share more information about the topic discussed above.
GeeksforGeeks has prepared a complete interview preparation course with premium videos, theory, practice problems, TA support and many more features. Please refer Placement 100 for details
- Count of integers in a range which have even number of odd digits and odd number of even digits
- Number of digits before the decimal point in the division of two numbers
- Find smallest possible Number from a given large Number with same count of digits
- Find count of digits in a number that divide the number
- Count of prime digits of a Number which divides the number
- Count of numbers between range having only non-zero digits whose sum of digits is N and number is divisible by M
- Smallest number dividing minimum number of elements in the Array
- Largest number dividing maximum number of elements in the array
- Smallest number dividing minimum number of elements in the array | Set 2
- Given a number N in decimal base, find number of its digits in any base (base b)
- Given a number N in decimal base, find the sum of digits in any base B
- Count digits in given number N which divide N
- Count of Prime digits in a Number
- Count total number of digits from 1 to n
- C program to Count the digits of a number