Problem 5 : Smallest multiple
2520 is the smallest number that can be divided by each of the numbers from 1 to 10 without any remainder.
What is the smallest positive number that is evenly divisible by all of the numbers from 1 to 20?
思路:(补充一点,之前我在matlab的live script运行,跑起来比较慢,但是后来我在command window运行时很快,仅需要 16.526701 秒,果然matlab运行很快,只怪我太年轻了!)
据题意2520是最小的能被1到10中任意一个数整除的数,求能被1到20中任意一个数整除的最小整数,我的想法还是遍历,比如说任意一个数,设置一个循环从20到1,如果能被20整除那么接着除19, 一直到2,如果都行那就输出,不行就pass,下一个接着来。说得好轻巧,但是采用的这个方法非常的暴力,就是传说中的暴力破解法----穷举法,用matlab跑这个程序花了大概半个小时,这段时间内,守着屏幕,独自怎生的黑?简直就是望穿秋水,一边焦灼的等待。