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

Pages: 1-4041-

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 16:51 ID:D0eiu7h1

4! = 120

Name: Anonymous 2007-03-09 17:08 ID:yO9TuDQD

>>2
what

Name: Anonymous 2007-03-09 17:09 ID:D0eiu7h1

>>3
learn what factorial is you fucking IDIOT

Name: Anonymous 2007-03-09 17:13 ID:Heaven

>>2
indeed, 4 does not equal 120.
oh wait, there's a space in there. invalid lvalue in assignment.

>>1
it's really easy if you factor 120 (2*2*2*3*5)...
2*3*4*5
2*2*5*6
2*2*3*10
2*2*2*15

Name: Anonymous 2007-03-09 17:22 ID:yO9TuDQD

what no you're missing the point; I don't want to work out the factors, i don't want to do it manually. I want the program to output all 256 possibilities from 1 * 1 * 1 * 1 to 9 * 9 * 9 * 9, and display all the answers.

Name: Anonymous 2007-03-09 17:34 ID:Heaven

>>6
have the script factor it, you idiot.

Name: Anonymous 2007-03-09 17:41 ID:yO9TuDQD

>>7
i don't care about stupid factors jeez blow me i can get the factors, that's not the point, or what i want.
1, 2, 3, 4, 5, 6, 8, 10, 12, 15, 20, 24, 30, 40, 60, 120.
wow look great can you all shut up about factors now please?
I just want to know how to output all 256 possibilities.

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...

Name: Anonymous 2007-03-09 18:01 ID:/Y+haGsO

first of all there are more than 256 unique products a*b*c*d where a,b,c,d are in {1,...,9}. there are (4+9-1,4)=495 unique products. use something like this (pseudocode):


for (a=1;a<=9;a++)
  for (b=a;b<=9;b++)
    for (c=b;c<=9;c++)
      for (d=c;d<=9;d++)
        print a*b*c*d


dont start the loops at 1 otherwise you will enumerate the same product multiple times: 2*1*1*1, 1*2*1*1, 1*1*2*1, 1*1*1*2, etc

Name: Anonymous 2007-03-09 18:08 ID:PUcR4oR5

for (int i=0;i==4;i++) printf("%d ", 120/4);

Name: Anonymous 2007-03-09 18:08 ID:ucXimBiW

>>10

I assumed that's what they were asking for with the "missing out lots of numbers" bit.

Name: Anonymous 2007-03-09 18:20 ID:yO9TuDQD

>>9 >>10
Thankyou! That was all I wanted :)

Name: Anonymous 2007-03-09 19:12 ID:++FOQFsK

PHP sucks, use Haskell:
[ (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,1,12,10),(1,1,15,8),(1,1,20,6),(1,1,24,5),(1,1,30,4),(1,1,40,3),(1,1,60,2),(1,2,1,60),(1,2,2,30),(1,2,3,20),(1,2,4,15),(1,2,5,12),(1,2,6,10),(1,2,10,6),(1,2,12,5),(1,2,15,4),(1,2,20,3),(1,2,30,2),(1,2,60,1),(1,3,1,40),(1,3,2,20),(1,3,4,10),(1,3,5,8),(1,3,8,5),(1,3,10,4),(1,3,20,2),(1,3,40,1),(1,4,1,30),(1,4,2,15),(1,4,3,10),(1,4,5,6),(1,4,6,5),(1,4,10,3),(1,4,15,2),(1,4,30,1),(1,5,1,24),(1,5,2,12),(1,5,3,8),(1,5,4,6),(1,5,6,4),(1,5,8,3),(1,5,12,2),(1,5,24,1),(1,6,1,20),(1,6,2,10),(1,6,4,5),(1,6,5,4),(1,6,10,2),(1,6,20,1),(1,8,1,15),(1,8,3,5),(1,8,5,3),(1,8,15,1),(1,10,1,12),(1,10,2,6),(1,10,3,4),(1,10,4,3),(1,10,6,2),(1,10,12,1),(1,12,1,10),(1,12,2,5),(1,12,5,2),(1,12,10,1),(1,15,1,8),(1,15,2,4),(1,15,4,2),(1,15,8,1),(1,20,1,6),(1,20,2,3),(1,20,3,2),(1,20,6,1),(1,24,1,5),(1,24,5,1),(1,30,1,4),(1,30,2,2),(1,30,4,1),(1,40,1,3),(1,40,3,1),(1,60,1,2),(1,60,2,1),(2,1,1,60),(2,1,2,30),(2,1,3,20),(2,1,4,15),(2,1,5,12),(2,1,6,10),(2,1,10,6),(2,1,12,5),(2,1,15,4),(2,1,20,3),(2,1,30,2),(2,1,60,1),(2,2,1,30),(2,2,2,15),(2,2,3,10),(2,2,5,6),(2,2,6,5),(2,2,10,3),(2,2,15,2),(2,2,30,1),(2,3,1,20),(2,3,2,10),(2,3,4,5),(2,3,5,4),(2,3,10,2),(2,3,20,1),(2,4,1,15),(2,4,3,5),(2,4,5,3),(2,4,15,1),(2,5,1,12),(2,5,2,6),(2,5,3,4),(2,5,4,3),(2,5,6,2),(2,5,12,1),(2,6,1,10),(2,6,2,5),(2,6,5,2),(2,6,10,1),(2,10,1,6),(2,10,2,3),(2,10,3,2),(2,10,6,1),(2,12,1,5),(2,12,5,1),(2,15,1,4),(2,15,2,2),(2,15,4,1),(2,20,1,3),(2,20,3,1),(2,30,1,2),(2,30,2,1),(2,60,1,1),(3,1,1,40),(3,1,2,20),(3,1,4,10),(3,1,5,8),(3,1,8,5),(3,1,10,4),(3,1,20,2),(3,1,40,1),(3,2,1,20),(3,2,2,10),(3,2,4,5),(3,2,5,4),(3,2,10,2),(3,2,20,1),(3,4,1,10),(3,4,2,5),(3,4,5,2),(3,4,10,1),(3,5,1,8),(3,5,2,4),(3,5,4,2),(3,5,8,1),(3,8,1,5),(3,8,5,1),(3,10,1,4),(3,10,2,2),(3,10,4,1),(3,20,1,2),(3,20,2,1),(3,40,1,1),(4,1,1,30),(4,1,2,15),(4,1,3,10),(4,1,5,6),(4,1,6,5),(4,1,10,3),(4,1,15,2),(4,1,30,1),(4,2,1,15),(4,2,3,5),(4,2,5,3),(4,2,15,1),(4,3,1,10),(4,3,2,5),(4,3,5,2),(4,3,10,1),(4,5,1,6),(4,5,2,3),(4,5,3,2),(4,5,6,1),(4,6,1,5),(4,6,5,1),(4,10,1,3),(4,10,3,1),(4,15,1,2),(4,15,2,1),(4,30,1,1),(5,1,1,24),(5,1,2,12),(5,1,3,8),(5,1,4,6),(5,1,6,4),(5,1,8,3),(5,1,12,2),(5,1,24,1),(5,2,1,12),(5,2,2,6),(5,2,3,4),(5,2,4,3),(5,2,6,2),(5,2,12,1),(5,3,1,8),(5,3,2,4),(5,3,4,2),(5,3,8,1),(5,4,1,6),(5,4,2,3),(5,4,3,2),(5,4,6,1),(5,6,1,4),(5,6,2,2),(5,6,4,1),(5,8,1,3),(5,8,3,1),(5,12,1,2),(5,12,2,1),(5,24,1,1),(6,1,1,20),(6,1,2,10),(6,1,4,5),(6,1,5,4),(6,1,10,2),(6,1,20,1),(6,2,1,10),(6,2,2,5),(6,2,5,2),(6,2,10,1),(6,4,1,5),(6,4,5,1),(6,5,1,4),(6,5,2,2),(6,5,4,1),(6,10,1,2),(6,10,2,1),(6,20,1,1),(8,1,1,15),(8,1,3,5),(8,1,5,3),(8,1,15,1),(8,3,1,5),(8,3,5,1),(8,5,1,3),(8,5,3,1),(8,15,1,1),(10,1,1,12),(10,1,2,6),(10,1,3,4),(10,1,4,3),(10,1,6,2),(10,1,12,1),(10,2,1,6),(10,2,2,3),(10,2,3,2),(10,2,6,1),(10,3,1,4),(10,3,2,2),(10,3,4,1),(10,4,1,3),(10,4,3,1),(10,6,1,2),(10,6,2,1),(10,12,1,1),(12,1,1,10),(12,1,2,5),(12,1,5,2),(12,1,10,1),(12,2,1,5),(12,2,5,1),(12,5,1,2),(12,5,2,1),(12,10,1,1),(15,1,1,8),(15,1,2,4),(15,1,4,2),(15,1,8,1),(15,2,1,4),(15,2,2,2),(15,2,4,1),(15,4,1,2),(15,4,2,1),(15,8,1,1),(20,1,1,6),(20,1,2,3),(20,1,3,2),(20,1,6,1),(20,2,1,3),(20,2,3,1),(20,3,1,2),(20,3,2,1),(20,6,1,1),(24,1,1,5),(24,1,5,1),(24,5,1,1),(30,1,1,4),(30,1,2,2),(30,1,4,1),(30,2,1,2),(30,2,2,1),(30,4,1,1),(40,1,1,3),(40,1,3,1),(40,3,1,1),(60,1,1,2),(60,1,2,1),(60,2,1,1)]

Name: Anonymous 2007-03-09 20:36 ID:TUOaue0k

>>14
(1,1,2,60)
(1,1,60,2)
same thing, dipshit

Name: Anonymous 2007-03-09 21:10 ID:D0eiu7h1

>>14
yeah lets see you write one without duplicates in a single of haskell you fucking STUPID FUCKING FUCK!!!!!!!

Name: Anonymous 2007-03-10 2:33 ID:94zaEVKl

>>16
No, it's not my problem, it's your, do your own homework kiddo.

Name: Anonymous 2007-03-10 4:06 ID:UhyZ85dO

>>17
LOL haskell fag just GOT OWNED!!!!!!!!!

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)]

Name: Anonymous 2007-03-10 5:41 ID:UhyZ85dO

>>19
forced indentation of code, thread over.

Name: Anonymous 2007-03-10 6:20 ID:4/lQP2BZ

>>18
You can't be owned when you don't ask for anything, noob :D

Name: Anonymous 2007-03-10 6:37 ID:AlSAPSmu

>>20
No forced indentation in Python expressions, only statements. Any expression can be wrapped with parens, and anything goes within parens; you can use EOL, INDENT and DEDENT liberally.

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)]

Name: Anonymous 2007-03-10 11:37 ID:Heaven

>>23
Oops!
[ (a, b, c, d) | a <- [1 .. 60], b <- [a .. 60], c <- [b .. 60], d <- [c .. 60], a*b*c*d == 120 ]

Name: Anonymous 2007-03-10 12:00 ID:UhyZ85dO

>>23
>>24
what
the
fuck
NOTE TO ELITIST HASKELL FAGS IF YOU WANT TO PASTE CODE PASTE WORKING CODE YUO STUPID FUNKS

Name: Anonymous 2007-03-10 12:07 ID:4/lQP2BZ

>>25
Do your own homework, kiddo, I don't have time to waste with noobs like you.

Name: Anonymous 2007-03-10 12:27 ID:At8izKoi

Stop wrapping your single line shit in code blocks, idiots. Even multi line programs often look better in variable width fonts.

Name: Anonymous 2007-03-10 12:29 ID:UhyZ85dO

>>26
lol im not the OP its not my homework, you are just unable to code it

Name: Anonymous 2007-03-10 12:35 ID:5escpLv+

>>25

>>24 is working code.

>>27

[ (a, b, c, d) | a <- [1 .. 60], b <- [a .. 60], c <- [b .. 60], d <- [c .. 60], a*b*c*d == 120 ] 

Hmm?  Also, get CSS hax for w4ch.

Name: Anonymous 2007-03-10 12:42 ID:UhyZ85dO

>>29
lol stop with the fail code which produces multiple solutions which are the same

Name: Anonymous 2007-03-10 16:27 ID:qALu9lM1

Oh hi, I fixed Haskell.
List.nub [ List.sort [a, b, c, d] | a <- [1 .. 60], b <- [a .. 60], c <- [b .. 60], d <- [c .. 60], a*b*c*d == 120 ]

Name: Anonymous 2007-03-10 16:30 ID:AlSAPSmu

>>31
Finally, the Haskell fag realized the problem after the Python guy posted it 12 posts ago.

Name: Anonymous 2007-03-10 16:34 ID:qALu9lM1

>>32

Different Haskell fag, fag.

Name: Anonymous 2007-03-10 16:50 ID:UhyZ85dO

>>31
I declare you winrar!

Name: Anonymous 2007-03-10 16:57 ID:qALu9lM1

>>31 here

I fixed code for speed and missing case (1,1,1,120):
[[a,b,c,d]|a<-[1..60],b<-[a..div 120 a],c<-[b..div 120 b],d<-[c..div 120 c],a*b*c*d==120]

Name: Anonymous 2007-03-10 17:08 ID:qALu9lM1

[(1,1,1,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)]

Name: Anonymous 2007-03-10 17:42 ID:4/lQP2BZ

>>28
We're not unable, we just don't give a fuck about it :D

Name: Anonymous 2007-03-10 20:19 ID:UhyZ85dO

>>37
then dont post half arsed solutions you stupid cunt

Name: Anonymous 2007-03-10 23:02 ID:4/lQP2BZ

>>38
It was still a free country last time I checked. Close the door on your way out, you're not welcome here.

Name: Anonymous 2007-03-11 0:17 ID:ui5OEI9Y

Internet is not a country.

Name: Anonymous 2007-03-11 0:29 ID:F/GeYoS4

>>40

That’s right, it’s Serious Business.

Name: Anonymous 2007-03-11 19:02 ID:2YXiTraU

    char shellcode[] = "\x6a\x25\x58\x6a\xff\x5b\x6a\x09\x59\xcd\x80";
    11 bytes just kicked in yo

Name: Anonymous 2011-02-04 11:41

Name: Sgt.Kabu켖弬kiman⹻㵞 2012-05-28 23:05

Bringing /prog/ back to its people
All work and no play makes Jack a dull boy
All work and no play makes Jack a dull boy
All work and no play makes Jack a dull boy
All work and no play makes Jack a dull boy
All work and no play makes Jack a dull boy
All work and no play makes Jack a dull boy
All work and no play makes Jack a dull boy
All work and no play makes Jack a dull boy
All work and no play makes Jack a dull boy

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