views:

248

answers:

1

Yes I did see the questions similar to this already posted here (notably this one).

But. Am i crazy, or can the size of the square also be a non-integer? For example, in a 2x3 rectangle, one solution is squares that are .2x.2

How can i create a function to find the number of possible square sizes?

+3  A: 

Turn it back into an integer problem. Suppose you want the smallest quantum of length to be 0.1, just multiply all dimensions by 10 and you are back to an integer problem. Then at the end, scale it back down.

This general technique is used a lot in embedded software where you don't want to play with floating point too much, but need to deal in fractions, such as fractions of a second.

Tony van der Peet