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 5:38 ID:AlSAPSmu

A single line of Python can do it:

dict.fromkeys(tuple(sorted((a, b, c, d))) for a in xrange(1, 61) for b in xrange(1, 61) for c in
 xrange(1, 61) for d in xrange(1, 61) if a * b * c * d == 120).keys()


[(2, 2, 5, 6), (1, 3, 5, 8), (1, 1, 6, 20), (1, 1, 3, 40), (1, 1, 2, 60), (1, 3, 4, 10), (1, 2, 5, 12), (1, 1, 10, 12), (1, 2, 2, 30), (1, 1, 4, 30), (1, 2, 3, 20), (1, 4, 5, 6), (1, 1, 5, 24), (2, 2, 3, 10), (1, 2, 6, 10), (2, 3, 4, 5), (2, 2, 2, 15), (1, 1, 8, 15), (1, 2, 4, 15)]

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