SQL> ed
Wrote file afiedt.buf
1 declare
2 n number;
3 i number;
4 counter number;
5 begin
6 n:=&n;
7 i:=1;
8 counter:=0;
9 if n=1
10 then dbms_output.put_line('1 is a prime No.');
11 else if n=2
12 then dbms_output.put_line('2 is even prime');
13 else
14 for i in 1..n loop
15 if mod(n,i)=0
16 then counter:=counter+1;
17 end if;
18 end loop;
19 end if;
20 if counter=2
21 then dbms_output.put_line(n||' is a prime No.');
22 else
23 dbms_output.put_line(n||' is a not prime No.');
24 end if;
25* end
我收到以下错误,我不明白。任何人都可以解释是什么造成的?素数码 - 请帮我解决这个错误('如果丢失'?)
SQL>/
Enter value for n: 8
old 6: n:=&n;
new 6: n:=8;
end
*
ERROR at line 25:
ORA-06550: line 25, column 3:
PLS-00103: Encountered the symbol "end-of-file" when expecting one of the
following:
if
请解释一下你的问题 - 你想要你的代码做什么以及它做什么? – Mikaveli 2011-01-30 10:58:28
注:1通常不被视为素数。请参阅:http://mathworld.wolfram.com/PrimeNumber.html。 “一个素数......是一个正整数p> 1,除1和它自身之外没有正整数除数。” “数字1是一个既不是素数又不是复合数的特殊情况(Wells 1986,p.31)尽管数字1曾被认为是素数(Goldbach 1742; Lehmer 1909,1914; Hardy and Wright 1979,p 11; Gardner 1984,pp.86-87; Sloane和Plouffe 1995,第33页; Hardy 1999,第46页)。 – 2011-01-31 20:14:46