Data Structure & Algorithm: Level-1 Problem #30. Nearest Divisors

Given a integer, find out its nearest pair of divisors.

Sample Input: 28

Sample Output: [4, 7]

With the number of 28, there are three pairs of divisors: [1, 28], [2, 14] and [4, 7]. Among them, the pair of [4, 7] is the nearest one.


数据结构和算法:初级练习题 #30 – 最接近因子


给定一个整数,找出所有因子当中最接近的一对。

输入样例: 28

输出样例:[4, 7]

数字28总共有三对因子:[1, 28], [2, 14], [4, 7]。这些因子当中相互最接近的一对是 [4, 7]。


Python Solution

Nearest Divisors