Solver Factor a Number
Algebra
->
Divisibility and Prime Numbers
-> Solver Factor a Number
Log On
Algebra: Divisibility and Prime Numbers
Section
Solvers
Solvers
Lessons
Lessons
Answers archive
Answers
Source code of 'Factor a Number'
This Solver (Factor a Number)
was created by by
Shin123(626)
:
View Source
,
Show
,
Put on YOUR site
About Shin123
:
Just a kid who solves math problems for fun :)
==section input Find factors of *[input num=100]. ==section solution perl unless($num=~/^\d+$/) { print "<font color=\"red\" size=\"5\">Positive whole numbers only.</font>\n"; return; } my $factors = solve("factor_any_number",$num); my @factors1 = split(",",$factors); $length = @factors1; if($length==1){ print("Since $num is a prime number, it can't be factored."); return; } my $num1 = $num; for(my $i = 0;$i<($length-1);$i++) { print("$num1 is divisible by " . (@factors1[$i]) . ". $num1 ÷ ".(@factors1[$i])."="); $num1=$num1/(@factors1[$i]); print "$num1.<br/>"; } print("$num1 is a prime number, so it is not divisible by anything.<br/>"); print("So the prime factorization of $num is ".join("×",@factors1)."."); ==section output ==section check ==section practice perl my $factor1 = randint(2,5); my $factor2 = randint(2,3); my $factor3 = randint(3,5); my $factor4 = randint(2,3); $num = $factor1*$factor2*$factor3*$factor4;