The post Project Euler 207 Solution appeared first on Dreamshire.
]]>For some positive integers k, there exists an integer partition of the form 4^{t} = 2^{t} + k,
where 4^{t}, 2^{t}, and k are all positive integers and t is a real number.
The first two such partitions are 4^{1} = 2^{1} + 2 and 4^{1.5849625…} = 2^{1.5849625…} + 6.
Partitions where t is also an integer are called perfect.
For any m ≥ 1 let P(m) be the proportion of such partitions that are perfect with k ≤ m.
Thus P(6) = 1/2.
In the following table are listed some values of P(m)
P(5) = 1/1
P(10) = 1/2
P(15) = 2/3
P(20) = 1/2
P(25) = 1/2
P(30) = 2/5
…
P(180) = 1/4
P(185) = 3/13
Find the smallest m for which P(m) < 1/12345
The post Project Euler 207 Solution appeared first on Dreamshire.
]]>The post Project Euler 172 Solution appeared first on Dreamshire.
]]>How many 18-digit numbers n (without leading zeros) are there such that no digit occurs more than three times in n?
from Euler import binomial
digits, base, max_r = 18, 10, 3
def nd(d,b):
if b>1:
return sum(nd(d-r, b-1)*binomial(d,r) for r in xrange(min(d+1, max_r+1)))
return d <= max_r
print "There are", nd(digits, base) * (base-1)/base,
print digits, "digit numbers such that no digit occurs more than", max_r,
print "times in base", base
Use this link to get the Project Euler 172 Solution Python source.The post Project Euler 172 Solution appeared first on Dreamshire.
]]>The post Project Euler 163 Solution appeared first on Dreamshire.
]]>Consider an equilateral triangle in which straight lines are drawn from each vertex to the middle of the opposite side, such as in the size 1 triangle in the sketch below.
Sixteen triangles of either different shape or size or orientation or location can now be observed in that triangle. Using size 1 triangles as building blocks, larger triangles can be formed, such as the size 2 triangle in the above sketch. One-hundred and four triangles of either different shape or size or orientation or location can now be observed in that size 2 triangle.
It can be observed that the size 2 triangle contains 4 size 1 triangle building blocks. A size 3 triangle would contain 9 size 1 triangle building blocks and a size n triangle would thus contain n^{2} size 1 triangle building blocks.
If we denote T(n) as the number of triangles present in a triangle of size n, then
T(1) = 16
T(2) = 104
Find T(36).
The post Project Euler 163 Solution appeared first on Dreamshire.
]]>The post Project Euler 190 Solution appeared first on Dreamshire.
]]>Let S_{m} = (x_{1}, x_{2}, … , x_{m}) be the m-tuple of positive real numbers with x_{1} + x_{2} + … + x_{m} = m for which P_{m} = x_{1} * x_{2}^{2} * … * x_{m}^{m} is maximised.
For example, it can be verified that [P_{10}] = 4112 ([ ] is the integer part function).
Find Σ[P_{m}] for 2 ≤ m ≤ 15.
The post Project Euler 190 Solution appeared first on Dreamshire.
]]>The post Project Euler 318 Solution appeared first on Dreamshire.
]]>
Consider the real number √2+√3.
When we calculate the even powers of √2+√3
we get:
(√2+√3)^{2} = 9.898979485566356…
(√2+√3)^{4} = 97.98979485566356…
(√2+√3)^{6} = 969.998969071069263…
(√2+√3)^{8} = 9601.99989585502907…
(√2+√3)^{10} = 95049.999989479221…
(√2+√3)^{12} = 940897.9999989371855…
(√2+√3)^{14} = 9313929.99999989263…
(√2+√3)^{16} = 92198401.99999998915…
It looks like that the number of consecutive nines at the beginning of the fractional part of these powers is non-decreasing.
In fact it can be proven that the fractional part of (√2+√3)^{2n} approaches 1 for large n.
Consider all real numbers of the form √p+√q with p and q positive integers and p<q, such that the fractional part
of (√p+√q)^{2n} approaches 1 for large n.
Let C(p,q,n) be the number of consecutive nines at the beginning of the fractional part of
(√p+√q)^{2n}.
Let N(p,q) be the minimal value of n such that C(p,q,n) ≥ 2011.
Find ∑N(p,q) for p+q ≤ 2011.
#Project Euler Problem 318 Solution
from math import sqrt, log10, ceil
s, L = 0, 2011
for p in xrange(1, L):
for q in xrange(p+1, L-p+1):
c = p + q - 2*sqrt(p*q)
if c < 1:
s += ceil(-L / log10(c))
print "sum of N(p,q) for p+q <=", L, "is", int(s)
Use this link to get the Project Euler 318 Solution Python 2.7 source.The post Project Euler 318 Solution appeared first on Dreamshire.
]]>The post Project Euler 317 Solution appeared first on Dreamshire.
]]>A firecracker explodes at a height of 100 m above level ground. It breaks into a large number of very small fragments, which move in every direction; all of them have the same initial velocity of 20 m/s.
We assume that the fragments move without air resistance, in a uniform gravitational field with g=9.81 m/s^{2}.
Find the volume (in m^{3}) of the region through which the fragments move before reaching the ground.
Give your answer rounded to four decimal places.
The post Project Euler 317 Solution appeared first on Dreamshire.
]]>The post Project Euler 288 Solution appeared first on Dreamshire.
]]>For any prime p the number N(p,q) is defined by
N(p,q) = ∑_{n=0 to q} T_{n}*p^{n}
with T_{n} generated by the following random number generator:
S_{0} = 290797
S_{n+1} = S_{n}^{2} mod 50515093
T_{n} = S_{n} mod p
Let Nfac(p,q) be the factorial of N(p,q).
Let NF(p,q) be the number of factors p in Nfac(p,q).
You are given that NF(3,10000) mod 3^{20}=624955285.
Find NF(61,10^{7}) mod 61^{10}
The post Project Euler 288 Solution appeared first on Dreamshire.
]]>The post Project Euler 183 Solution appeared first on Dreamshire.
]]>Let N be a positive integer and let N be split into k equal parts, r = N/k, so that N = r + r + … + r.
Let P be the product of these parts, P = r × r × … × r = r^{k}.
For example, if 11 is split into five equal parts, 11 = 2.2 + 2.2 + 2.2 + 2.2 + 2.2, then P = 2.2^{5} = 51.53632.
Let M(N) = P_{max} for a given value of N.
It turns out that the maximum for N = 11 is found by splitting eleven into four equal parts which leads to P_{max} = (11/4)^{4}; that is, M(11) = 14641/256 = 57.19140625, which is a terminating decimal.
However, for N = 8 the maximum is achieved by splitting it into three equal parts, so M(8) = 512/27, which is a non-terminating decimal.
Let D(N) = N if M(N) is a non-terminating decimal and D(N) = -N if M(N) is a terminating decimal.
For example, ΣD(N) for 5 ≤ N ≤ 100 is 2438.
Find ΣD(N) for 5 ≤ N ≤ 10000.
The post Project Euler 183 Solution appeared first on Dreamshire.
]]>The post Project Euler 371 Solution appeared first on Dreamshire.
]]>Oregon licence plates consist of three letters followed by a three digit number (each digit can be from [0..9]).
While driving to work Seth plays the following game:
Whenever the numbers of two licence plates seen on his trip add to 1000 that’s a win.
E.g. MIC-012 and HAN-988 is a win and RYU-500 and SET-500 too. (as long as he sees them in the same trip).
Find the expected number of plates he needs to see for a win.
Give your answer rounded to 8 decimal places behind the decimal point.
Note: We assume that each licence plate seen is equally likely to have any three digit number on it.
The post Project Euler 371 Solution appeared first on Dreamshire.
]]>The post Project Euler 140 Solution appeared first on Dreamshire.
]]>Consider the infinite polynomial series A_{G}(x) = xG_{1} + x^{2}G_{2} + x^{3}G_{3} + …, where G_{k} is the kth term of the second order recurrence relation G_{k} = G_{k−1} + G_{k−2}, G_{1} = 1 and G_{2} = 4; that is, 1, 4, 5, 9, 14, 23, … .
For this problem we shall be concerned with values of x for which A_{G}(x) is a positive integer.
The corresponding values of x for the first five natural numbers are shown below.
We shall call A_{G}(x) a golden nugget if x is rational, because they become increasingly rarer; for example, the 20th golden nugget is 211345365.
Find the sum of the first thirty golden nuggets.
The post Project Euler 140 Solution appeared first on Dreamshire.
]]>