一种基于Python的较快速的水仙花数的搜寻方法

2025-01-04 20:24:08

1、首先,我需要加载两个模块:from itertools import combinations_with_replacementfrom time import clock

一种基于Python的较快速的水仙花数的搜寻方法

3、然后开始搜寻水仙花数,分别搜寻3位数到19位数的水仙花数,同时测试代码运行时间。

一种基于Python的较快速的水仙花数的搜寻方法

5、9位数到15位数的水仙花数,用时都不超过1分钟。

一种基于Python的较快速的水仙花数的搜寻方法
猜你喜欢