16 Jan
2014
16 Jan
'14
08:58
On Jan 16, 2014, at 8:35 AM, Hendrik Boom <hendrik@topoi.pooq.com> wrote:
If all you want is a boolean, maybe it would be simpler to reduce the fraction to lowest terms (might this already have been done?) and then checking if the denominator is divisible by 2 or 5.
I guess you mean that 2 and 5 are the only factors (for example 1/140 has an infinite decimal representation but the denominator is divisible by 2, 5 and 7). Marc (define (has-finite-decimal-representation? n) ;; n is a positive real (define (remove-factor factor n) (if (zero? (modulo n factor)) (remove-factor factor (quotient n factor)) n)) (= 1 (remove-factor 2 (remove-factor 5 (denominator (inexact->exact n))))))