Problem 58229. Easy Sequences 112: Almost Golden Integer Rectangles 1
The ancient Greeks consider the golden rectangle as the most aesthetically pleasing rectangular shape. Unfortunately for the ancients this ratio cannot be achieved if the sides are rational numbers let alone integers.
In this problem we are asked to find the perimeter of the rectangle with integer sides with area within the given area interval
, and in which the side ratio is as close as possible to the golden ratio, that is the absolute value,
, is minimized.
For example, if
and
, the correct dimensions should be
, therefore the perimeter should be
:
>> A1 = 20000; A2 = 30000; phi = (sqrt(5)+1)/2; a = Inf;
>> for i = 1:A2
for j = ceil(A1/i):floor(A2/i)
r = max(j/i,i/j);
if abs(r-phi) < a
p = 2 * (i + j);
a = abs(r-phi);
end
end
end
>> p
p =
644
Solution Stats
Solution Comments
Show commentsProblem Recent Solvers3
Suggested Problems
-
Back to basics 12 - Input Arguments
605 Solvers
-
Choose the best fitting dominoes
209 Solvers
-
Square Digits Number Chain Terminal Value (Inspired by Project Euler Problem 92)
232 Solvers
-
Right Triangle Side Lengths (Inspired by Project Euler Problem 39)
1889 Solvers
-
Create a matrix with difference of each row of input matrix
75 Solvers
More from this Author116
Problem Tags
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!