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-09 17:57 ID:ucXimBiW

<?php

for ( $v1 = 1; $v1 < 10; $v1++ )
{
 for ( $v2 = 1; $v2 < 10; $v2+ )
 {
  for ( $v3 = 1; $v3 < 10; $v3++ )
  {
   for ( $v4 = 1; $v4 < 10; $v4++ )
   {
    $v5 = $v1 * $v2 * $v3 * $v4;
   
    print "$v1 * $v2 * $v3 * $v4 = $v5 <br>\n";
   }
  }
 }
}

?>

I think. It should go:

1 * 1 * 1 * 1 = 1
1 * 1 * 1 * 2 = 2;
etc...

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