Problem 182084 · easy · Phase 01 Prerequisites & Setup

Biggest Square Tile

functions · gcd · loops

You are tiling a rectangular floor that is width by height centimetres using identical square tiles, with no cutting and no gaps. Write tile_size(width, height) that returns the side length of the largest square tile that works.

Examples

Input:  width = 12, height = 18
Output: 6
Explanation: 6 cm tiles fit exactly (2 by 3). 12 cm tiles would not fit the 18 cm side.

Input:  width = 7, height = 5
Output: 1

Constraints

  • 1 <= width, height <= 10**9

Goals

  • Recognise a gcd problem in disguise
  • Implement Euclid's algorithm with a loop
Starting Python…