#!/usr/bin/env perl use strict; use warnings; my $candidate = shift; my $candidate_string= ('x' x $candidate); while (1) { if (my ($factor,$rest) = $candidate_string=~ m/^(..+?)(\1+)$/) { print length($factor), "*"; $candidate /= length($factor); $candidate_string= ('x' x $candidate); } else { print $candidate; last; } } print "\n"; exit;
-QM
--
Quantum Mechanics: The dreams stuff is made of
In reply to Re: How not to do prime factorization
by QM
in thread How not to do prime factorization
by thisisdada
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |