Problem 58244. Easy Sequences 113: Almost Golden Integer Rectangles 2
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.
We define  as a function that calculates the perimeter of the rectangle with integer sides with area equal to A, and in which the side ratio is as close as possible to the golden ratio, that is the absolute value,
 as a function that calculates the perimeter of the rectangle with integer sides with area equal to A, and in which the side ratio is as close as possible to the golden ratio, that is the absolute value,  , is minimized.
, is minimized.
For example, if  , the correct dimensions should be
, the correct dimensions should be  , since the ratio
, since the ratio  is the closest we can get to ϕ for rectangle with area of
 is the closest we can get to ϕ for rectangle with area of  (see below code). Therefore,
 (see below code). Therefore,  .
.
>>  A = 20000; phi = (sqrt(5)+1)/2; a = Inf;
>>  for i = 1:A
      if mod(A,i) == 0
         j = A / i;
         r = max(j/i,i/j);
         if abs(r-phi) < a
            ds = [i j];
            a = abs(r-phi);
         end
      end
    end
>> ds
ds =
    125 160
In this problem, we are asked to evaluate the following summation:
that is, the sum of perimeter of all almost golden integer rectangles with areas from 1 to A.
For example, for  , summation output should be
, summation output should be  :
:
Solution Stats
Solution Comments
Show commentsProblem Recent Solvers2
Suggested Problems
- 
         Return a list sorted by number of occurrences 2839 Solvers 
- 
         
         1962 Solvers 
- 
         
         3389 Solvers 
- 
         High Precision Square Root (Inspired by Project Euler 80) 29 Solvers 
- 
         
         131 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!