147112613210319486499676296015469376140521397487772312539818224915030479615918413181667804881965140 978577602879012396476181147114517095334951755284774296929590260545569265720366451220763460675369225 562092691997648611896298415668747092796050814927021662304746378459453311470775199933251758665556263 651853490184370195055575968818253407088121287627256915970363971231352356863999999999999999999999999 999999999999999999999
That was fast!
It's not hard; just observe that order doesn't matter, and use a language with no overload (like, say... python?).
You mean overflow, which is what happened in the strip. :P
If I understand the puzzle correctly the answer is in the following link:
order is not important
this beat matlab. sample output:
i like the 'poop' thing :P
It bothers me that I don't know how to approach this problem...
find all prime numbers than connect the smallest to the largest in the formula x+y+xy (since the output is greatest when the numbers are closest) continue to so so until only 1 value is left
1.29700.... * 10^416
Key insight here is that the "x + y + x*y" operator is associative and commutative, which means that no matter what combinations you pick, the result will always be the same.
My python script agrees with Bronte
...and the reason that m(x,y)=x+y+xy is associative and commutative is that it's just ordinary multiplication in disguise: m(x,y)+1 = (x+1) (y+1). That means that the product of n+1 over all numbers n on the blackboard is an invariant, so it must end up at its initial value (2+1)(3+1)(5+1)(7+1)...(997+1), and thus the final number is 1 less than this product, QED.
<3 for this puzzle.
I liked this puzzle! I got to the point of realizing order doesn't matter, but still made the mistake of trying to calculate the product of primes and getting infinity...
Are there any easy ways to compute it without using a package with unlimited-length-integer support (Matlab / Mathematica / specialist libraries)? It would take quite a while to do by hand...
Is my following approach correct fr this puzzle,
got answer as Infinity..
but i din find min value for 'diff combinations', did i miss dat actually..?
You guys having problems with this in MATLAB? Works nicely:
p = vpa(primes(1000));
Probably those getting "inf" on program runs are really seeing "overflow error".
Argh! I'm such an idiot! I just spent an age and a half trying to figure out why all of my attempts yielded something far larger than what the answer actually was, and then when I actually read the question properly I realised that I'd been using the first 1000 primes, instead of the primes up to 1000.
This is my code in python:
# primes is all prime numbers between 1 and 1000
reduce(lambda a,b: a*b, [i+1 for i in primes]) - 1
My Haskell version
primes max = [ x | x <- [2..max], (==)  $ filter (\y -> y*(x `div` y) == x) [2..x-2] ]
spiked = foldl1 (\x y -> x+y+x*y)
spiked $ primes 1000
I used the infinite lazily-constructed list of primes and tookWhile (<1000) it.
There should really be something as a facebook "like" button for each comic :)
The stars at the top of the page let you rate them. Is that close enough?
I have the code already in place but with an /ignore/ tag. I'll remove the ignore and let's see how it goes with the facebook like code in place.
i have a close formula for that :D
R says integer overflow! bummer.
it's the sum, taken over all nonempty subsets of those primes, of the product of the elements of each subset.
Using J the result can easily be computed with this code: