Page 1 of 1

Problem 266

Posted: Mon Nov 30, 2009 7:29 am
by MrDrake
This is annoying... I've got 232...442, but there must be one larger!

EDIT: Never mind... there must be something wrong with my code somewhere, but changing a variable gave me the right answer!

Re: Problem 266

Posted: Fri Sep 17, 2010 4:09 pm
by sivakd
Not sure if asking this question would give away too much info, can this be solved with just 64 bit integers or like BigInteger type data types are needed?

Re: Problem 266

Posted: Fri Sep 17, 2010 6:09 pm
by jaap
That's a false dichotomy.

Re: Problem 266

Posted: Mon Sep 27, 2010 7:03 am
by sivakd
Thanks jaap. I managed to solve this problem without requiring big ints.

Re: Problem 266

Posted: Mon Nov 21, 2011 3:02 am
by JMW1994
What does this exactly mean?
Let p be the product of the primes below 190.

Re: Problem 266

Posted: Mon Nov 21, 2011 3:39 am
by thundre
JMW1994 wrote:What does this exactly mean?
Let p be the product of the primes below 190.
p = 2 * 3 * 5 * 7 * 11 * ... * 181

Re: Problem 266

Posted: Mon Nov 21, 2011 5:44 am
by JMW1994
Thanks.

problem 266

Posted: Fri Aug 21, 2015 10:31 am
by MYNick
https://projecteuler.net/problem=266

Hey guys, im trying to solve problem 266 for a couple of days now. Im pretty sure my solution is correct but the result is big red x. So i think i might do something wrong and i didn't understand the question correctly.
The question is:
lets take num which equal to the product of the prime numbers until 190 (the product of 42 numbers).
Now we take the sum and make a square root out of it. Now i need to find a product of group of numbers from the primes list (the 42 primes). For example: the third, fifth and 10th numbers will be the product. And i need to find the one that is closest to the sqrt of the real number. BUT it must be the closest from below, i can not pass the sqrt.

In the end i mod this product by (10**16)
I tried it in serval ways and i have no idea why the result is wrong. Can some one confrim something for me?
For the primes number in 100 (25 primes) my result is: 9552415660183671 (after mod). can some one confirm please?
The problem with the examples in the question is that they all 1 prime product and not product of couple of primes. Would be helpfull if real example will be added.

Re: problem 266

Posted: Fri Aug 21, 2015 2:59 pm
by DJohn
Your description sounds right to me (except in "Now we take the sum and make a square root out of it", it's the product, not the sum). N is the product of the primes below 190 (a very large number). You need to find the largest s such that s divides N and s <= sqrt(N).

It's easy to check small values by brute force. For primes below 20, I get N = 9699690 and s = 3094. For primes below 50 (the largest N that fits in 64 bit integers), s = 783152070. For the primes below 100, my result looks nothing like yours. Mine is 10xxxxxxxxxxxxxx65.

Re: problem 266

Posted: Fri Aug 21, 2015 3:50 pm
by MYNick
DJohn wrote:Your description sounds right to me (except in "Now we take the sum and make a square root out of it", it's the product, not the sum). N is the product of the primes below 190 (a very large number). You need to find the largest s such that s divides N and s <= sqrt(N).

It's easy to check small values by brute force. For primes below 20, I get N = 9699690 and s = 3094. For primes below 50 (the largest N that fits in 64 bit integers), s = 783152070. For the primes below 100, my result looks nothing like yours. Mine is 10xxxxxxxxxxxxxx65.
for below 100 i received 15xxxxxxxxxxxxxx65 but i got the right reslt for 190 now. I didnt receive the same result like you for 50 and i found the problem with my code.
I used sort in the wrong way in python.
I now solved it, thank you very much

Re: problem 266

Posted: Fri Aug 21, 2015 8:11 pm
by v6ph1
MYNick wrote:for below 100 i received 15xxxxxxxxxxxxxx65
As 2*3*...*97 = 2.3 * 10^36 and therefore the square is around 1.5(18..) * 10^18, DJohn must have a typing mistake.

Re: problem 266

Posted: Mon Aug 24, 2015 1:51 pm
by DJohn
v6ph1 wrote:
MYNick wrote:for below 100 i received 15xxxxxxxxxxxxxx65
DJohn must have a typing mistake.
Yes, I don't know how that happened. I get 15xxxxxxxxxxxxxx65 too.

I intended to give the value after the mod, but a) that doesn't start with 10 either, and b) I got the wrong number of digits. I'll just blame Friday afternoon.

Re: Problem 266

Posted: Tue Aug 16, 2016 8:01 am
by square1001
I got Wrong Answer in my program.

Let f(n) = (the answer where p = (product of primes below n) ). (after taking mod)

f(30) = 79534
f(50) = 783152070
f(70) = 2803119896185
f(100) = 840xxxxxxxxxx365 (16 digits)
f(150) = 60xxxxxxxxxx310 (15 digits)
f(190) = 884xxxxxxxxxx635 (16 digits)

What value is wrong?
Please tell me.

Re: Problem 266

Posted: Tue Aug 16, 2016 10:01 am
by v6ph1
The two last ones are definitely wrong - Did you take care about the range of 64Bit integers?

Re: Problem 266

Posted: Tue Aug 16, 2016 10:32 am
by square1001
Thanks, v6ph1!
I realized that my code had been overflowed...
Finally I got AC :D