Created
August 12, 2012 02:07
-
-
Save siosio/3328997 to your computer and use it in GitHub Desktop.
素数の時にJOJOと出力するPL/SQL
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
declare | |
function isPrime(input pls_integer) return boolean | |
is | |
begin | |
if input = 1 then | |
return false; | |
elsif input = 2 then | |
return true; | |
elsif mod(input, 2) = 0 then | |
return false; | |
else | |
for i in 3 .. (input - 1) | |
loop | |
if mod(input, i) = 0 then | |
return false; | |
end if; | |
end loop; | |
return true; | |
end if; | |
end; | |
begin | |
for i in 1 .. 100 | |
loop | |
if isPrime(i) then | |
dbms_output.put_line('JOJO'); | |
else | |
dbms_output.put_line(i); | |
end if; | |
end loop; | |
end; | |
/ |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment