### M_A_Noman's blog

By M_A_Noman, 2 months ago, Help me to know whether there are any processes in C++ by applying which I can find out whether the decimal representation of p/q is a rational number or an irrational number.

For example 10/4 = 2.5 is a rational number where 10/3 = 3.3333333 is an irrational number Comments (10)
 » 2 months ago, # | ← Rev. 2 →   p/q is always a rational number by definition.I think you meant whether decimal representation of p/q terminates or not, for that:let d=q/gcd(p,q)if d has only 2 and 5 as its prime factors, its decimal representation terminates, else it doesn't
•  » » 2 months ago, # ^ | ← Rev. 4 →   Thanks, brother I actually want to know that. But I also want to know if d has only 2 or only 5 as its prime factor then its decimal representation terminates or the number d should contain at least one 2 and one 5 in its prime factorization
•  » » » d can have both 2 and 5 as its prime factorsthe condition is: d should not have any other prime factor except 2 and 5
•  » » » » Let me explain my confusion  let p = 10 and q = 4 then gcd(p,q)=2 d = q/gcd(p,q)=2 d has prime factor 2 so this p/q is a rational number am I right?