Beefy Boxes and Bandwidth Generously Provided by pair Networks
Clear questions and runnable code
get the best and fastest answer
 
PerlMonks  

Re: Egyptian fractions (Golf Anyone?)

by Limbic~Region (Chancellor)
on Aug 25, 2006 at 15:22 UTC ( [id://569604]=note: print w/replies, xml ) Need Help??

Help for this page

Select Code to Download


  1. or download this
    use Math::Pari 'lcm';my($n,$d)=split/\//,shift;sub p{print"1/$_[0] "}w
    +hile(1){my
    $u=int$d/$n+1;p$u;my $l=lcm$d,$u;$n=$n*$l/$d-$l/$u;$d=$l;p($d),die$/if
    +$n==1}
    
  2. or download this
    ($n,$d)=split/\//,shift;sub p{print"1/$_[0] "}while(1){use Math::Pari
    lcm;$u=int$d/$n+1;p$u;$l=lcm$d,$u;$n=$n*$l/$d-$l/$u;$d=$l;p($d),die$/i
    +f$n==1}
    
  3. or download this
    #!/usr/bin/perl
    use strict;
    ...
        push @result, $den and last if $num == 1;    
    }
    print "1/$_ " for @result;
    

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others sharing their wisdom with the Monastery: (3)
As of 2024-04-26 01:21 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found