Return Styles: Pseud0ch, Terminal, Valhalla, NES, Geocities, Blue Moon. Entire thread

4 numbers that multiply to make 120

Name: Anonymous 2007-03-09 16:50 ID:yO9TuDQD

I suck pretty hard and can't figure out a way to do this, I am doing it in php, cause it's pretty much all I know..
so I tried
<?php
$v1=1;
$v2=1;
$v3=1;
$v4=1;
$v5=1;

while ($v4 < 10) {
    print "$v1 * $v2 * $v3 * $v4 = $v5<br>\n";
    $v1++;
    $v5 = $v1 * $v2 * $v3 * $v4;
    print "$v1 * $v2 * $v3 * $v4 = $v5<br>\n";
    $v2++;
    $v5 = $v1 * $v2 * $v3 * $v4;
    print "$v1 * $v2 * $v3 * $v4 = $v5<br>\n";
    $v3++;
    $v5 = $v1 * $v2 * $v3 * $v4;
    print "$v1 * $v2 * $v3 * $v4 = $v5<br>\n";
    $v4++;
    $v5 = $v1 * $v2 * $v3 * $v4;
    print "$v1 * $v2 * $v3 * $v4 = $v5<br>\n";
    }
 
print "FINISHED AND SHIT";
?>
which obviously doesn't work as it just does
1 * 1 * 1 * 1 = 1
2 * 1 * 1 * 1 = 2
2 * 2 * 1 * 1 = 4
2 * 2 * 2 * 1 = 8 etc.
missing out lots of numbers.

tl;dr how do i make php find out what 4 numbers multiply together to make 120.

Name: Anonymous 2007-03-10 11:36 ID:5escpLv+

>>16
Prelude> [ (a, b, c, d) | a <- [1 .. 60], b <- [1 .. 60], c <- [1 .. 60], d <- [1 .. 60], a*b*c*d == 120 ]
[(1,1,2,60),(1,1,3,40),(1,1,4,30),(1,1,5,24),(1,1,6,20),(1,1,8,15),(1,1,10,12),(1,2,2,30),(1,2,3,20),(1,2,4,15),(1,2,5,12),(1,2,6,10),(1,3,4,10),(1,3,5,8),(1,4,5,6),(2,2,2,15),(2,2,3,10),(2,2,5,6),(2,3,4,5)]

Newer Posts
Don't change these.
Name: Email:
Entire Thread Thread List