Sha256: aee6a4b7e88da9ec45ffa056092a02b05d602221a8b186187aa25cb079f7f293

Contents?: true

Size: 364 Bytes

Versions: 323

Compression:

Stored size: 364 Bytes

Contents

package Example;
use strict;
use warnings;

sub factors {
    my ($num) = @_;

	return [] if $num == 1;
    my @factors;
    my $i = 2;
	while ($i*$i <= $num) {
		my $div = $num/$i;
	    if ($div == int $div) {
            push @factors, $i;
            $num = $div;
            next;
        }
        $i++;
	}
	push @factors, $num;

    return \@factors;
}

1;

Version data entries

323 entries across 323 versions & 1 rubygems

Version Path
trackler-2.2.1.65 tracks/perl5/exercises/prime-factors/Example.pm
trackler-2.2.1.64 tracks/perl5/exercises/prime-factors/Example.pm
trackler-2.2.1.63 tracks/perl5/exercises/prime-factors/Example.pm
trackler-2.2.1.62 tracks/perl5/exercises/prime-factors/Example.pm
trackler-2.2.1.61 tracks/perl5/exercises/prime-factors/Example.pm
trackler-2.2.1.60 tracks/perl5/exercises/prime-factors/Example.pm
trackler-2.2.1.59 tracks/perl5/exercises/prime-factors/Example.pm
trackler-2.2.1.58 tracks/perl5/exercises/prime-factors/Example.pm
trackler-2.2.1.57 tracks/perl5/exercises/prime-factors/Example.pm
trackler-2.2.1.56 tracks/perl5/exercises/prime-factors/Example.pm
trackler-2.2.1.55 tracks/perl5/exercises/prime-factors/Example.pm
trackler-2.2.1.54 tracks/perl5/exercises/prime-factors/Example.pm
trackler-2.2.1.53 tracks/perl5/exercises/prime-factors/Example.pm
trackler-2.2.1.52 tracks/perl5/exercises/prime-factors/Example.pm
trackler-2.2.1.51 tracks/perl5/exercises/prime-factors/Example.pm
trackler-2.2.1.50 tracks/perl5/exercises/prime-factors/Example.pm
trackler-2.2.1.49 tracks/perl5/exercises/prime-factors/Example.pm
trackler-2.2.1.48 tracks/perl5/exercises/prime-factors/Example.pm
trackler-2.2.1.47 tracks/perl5/exercises/prime-factors/Example.pm
trackler-2.2.1.46 tracks/perl5/exercises/prime-factors/Example.pm