Yossi has asked for the wisdom of the Perl Monks concerning the following question:

This node falls below the community's minimum standard of quality and will not be displayed.

Replies are listed 'Best First'.
Re (tilly) 1: Factoring Decimal Digits
by tilly (Archbishop) on Jul 26, 2001 at 06:35 UTC
    I strongly recommend installing Math::Pari. The following short script will give you a picture of what state of the art factoring algorithms do:
    #! /usr/bin/perl use Math::Pari qw(:int factorint); print factorint($_), "\n" for @ARGV;
    Sample output:
    bash-2.01$ ./factor 491320487930121938479123 4839013210437894323 [48049,1;10225405064207828227,1] [11,2;36809477,1;1086455119,1]
    With barely a pause, even on this creaky old laptop.

    It does have to think, though, about:

    bash-2.01$ ./factor 4913204879301219384791234839013210437894323 [3,1;19,1;82471,1;17992995173,1;4100172797059,1;14167170962387,1]
(MeowChow - let's split the cash) Re: Factoring Decimal Digits
by MeowChow (Vicar) on Jul 26, 2001 at 03:30 UTC
    You supply the computer that breaks the theoretical limititations of physics, and I'll supply the code ;-)
      
    sub f { (1x(my$n=$_[0]))=~/(1+)\1+$/;my$p=$+[1];$p>1?(f($n/$p),f($p)):$n }
       MeowChow                                   
                   s aamecha.s a..a\u$&owag.print
      This code produces the wrong answer for 366178. It gives the prime factors for 366180.
      i have only PII350Mhz with 128 RAM... i just want the code for fun... (and to crush my computer down...)
        Ah, well then, I don't know if my code helps with the former, but for the latter, I heartily recommend one of these.
           MeowChow                                   
                       s aamecha.s a..a\u$&owag.print
Re: Factoring Decimal Digits
by I0 (Priest) on Jul 26, 2001 at 03:13 UTC
    my $n = shift or die; while( $n % 2 == 0 ){ print "2\n"; $n /= 2; } for( $_ = 3; $_ <= (my $sqrt || sqrt($n)); $_+= 2 ){ while( $n % $_ == 0 ){ print "$_\n"; $n /= $_; } } print "$n\n" if $n > 1
Re: Factoring Decimal Digits
by japhy (Canon) on Jul 26, 2001 at 00:15 UTC
    How could you be more vague? I don't understand what you're asking. Maybe you meant, "how can I factor an integer in Perl?"

    _____________________________________________________
    Jeff japhy Pinyan: Perl, regex, and perl hacker.
    s++=END;++y(;-P)}y js++=;shajsj<++y(p-q)}?print:??;

    A reply falls below the community's threshold of quality. You may see it by logging in.
Re: Factoring Decimal Digits
by Everlasting God (Beadle) on Jul 26, 2001 at 01:31 UTC
    Guess *somebody* reads Slashdot

    'The fickle fascination of and Everlasting God' - Billy Corgan, The Smashing Pumpkins
    A reply falls below the community's threshold of quality. You may see it by logging in.
(tye)Re: Factoring Decimal Digits
by tye (Sage) on Jul 26, 2001 at 11:10 UTC

    Sorry, I'm not very good at factoring in decimal but you can always convert to base 1: prime factorization using base 1 ;)

            - tye (but my friends call me "Tye")
10x for everyone
by Yossi (Initiate) on Jul 26, 2001 at 03:54 UTC
    thank you, PerlMonks!!! i will try the codes later... and then my computer crush... i am not going to win anything - i have a PII 350Mhz....