Beefy Boxes and Bandwidth Generously Provided by pair Networks
Think about Loose Coupling
 
PerlMonks  

Re^3: decimal to fraction

by pryrt (Abbot)
on Sep 12, 2017 at 13:47 UTC ( [id://1199199]=note: print w/replies, xml ) Need Help??


in reply to Re^2: decimal to fraction
in thread decimal to fraction

The numerator and denominator are mutually prime (no common factors), and thus the fraction is fully reduced. How else would you represent it as a fraction?

#!/usr/bin/env perl -l use warnings; use strict; ##### # [id://56906] for quick gcf sub gcf { my ($x, $y) = @_; ($x, $y) = ($y, $x % $y) while $y; return $x; } ###### print gcf(49420098210293,100000000000000); # prints 1 ##### use Math::Prime::Util qw/is_prime factor/; print is_prime(49420098210293); # not prime (I wasn't sure + when I started my answer) local $, = 'x'; print factor(49420098210293); # 113x4729x92481709 print factor(100000000000000); # 2x2x2x2x2x2x2x2x2x2x2x2x +2x2x5x5x5x5x5x5x5x5x5x5x5x5x5x5 # no common factors

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://1199199]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others wandering the Monastery: (3)
As of 2024-03-29 06:56 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found