|
3#
楼主 |
发表于 2010-12-10 01:32
|
只看该作者
2. 质因数分解:
初练, 感觉到写的很笨重, 不过运行的效果不错。
with t as (select 720 d from dual)
,t1 as (select rownum rn, rownum+1 n from t connect by level<d)
, fact(f_rn, f_n, f_num, canmod) as (
select 1, 2, d, sign(mod(d,2)) from t
union all
select rn, decode(canmod,0, f_n, f_n+1), decode(canmod,0, f_num/f_n, f_num),
sign(mod(decode(canmod,0, f_num/f_n, f_num), decode(canmod,0, f_n, f_n+1)))
from t1, fact where rn = f_rn + 1 and f_num>1
)
select f_n from fact where canmod=0
11 /
F_N
----------
2
2
2
2
3
3
5
7 rows selected
Executed in 0.156 seconds
SQL> |
|