ACCEPT p_1 PROMPT 'Please enter an integer between 30 and 70:'
DECLARE
num number := &p_1;
p number := 0;
q number := 1;
r number;
BEGIN
if num<30 or num>70 then
DBMS_OUTPUT.PUT_LINE('Invalid number.');
else
for k in 2..num loop
r := p + q;
p := q;
q := r;
end loop;
DBMS_OUTPUT.PUT_LINE('F('||num||') = '||r);
end if;
END; ------解决方案-------------------- 比如输入48,结果可以显示F(48)=xxxxxx, 怎么算F(45)和F(51)呢? ------解决方案-------------------- 增加2个变量不就行了吗?
numplus3 number := num+3;
numminus3 number := num-3;