Project Euler 85 - Counting Rectangles
Project Euler 85 - Counting Rectangles
Official link: https://projecteuler.net/problem=85
Thought Process
Thought Process
This screams combinatorics to me, notice that an N by M rectangle is essential (N+1) parallel horizontal lines and (M+1) parallel vertical lines. We want to to form all the rectangles possible, all rectangles are obviously formed by 2 horizontal and 2 vertical lines
By similarity M~2000 is the maximum value, so we make a double nested loop for N and M going from 1 to 2000, and keep track of the nearest value to 2,000,000
Interactive Code
Interactive Code
Please input an integer (yourinput)
Code will output N, M and N*M, where N*M is the area of the grid nearest to your input