Skip to content

Instantly share code, notes, and snippets.

@siosio
Created August 12, 2012 02:07
Show Gist options
  • Save siosio/3328997 to your computer and use it in GitHub Desktop.
Save siosio/3328997 to your computer and use it in GitHub Desktop.
素数の時にJOJOと出力するPL/SQL
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