Skip to content

Instantly share code, notes, and snippets.

@NekoTashi
Created September 25, 2014 15:13
Show Gist options
  • Save NekoTashi/29adc860bcf4b2ae4fc1 to your computer and use it in GitHub Desktop.
Save NekoTashi/29adc860bcf4b2ae4fc1 to your computer and use it in GitHub Desktop.
PL SQL
DECLARE
TYPE t_array IS TABLE OF integer INDEX BY varchar2(2000);
v_array t_array;
i integer;
j integer;
function es_primo(p int) return boolean
is
BEGIN
FOR k in reverse 2..(p-1) LOOP
IF mod(p, k) = 0 THEN
RETURN false;
END IF;
END LOOP;
RETURN true;
END;
BEGIN
FOR j IN 1.. 1000 LOOP
v_array(j) := j;
END LOOP;
i:=2;
LOOP
IF NOT ES_PRIMO(v_array(i)) then
v_array.delete(i);
END IF;
BEGIN
dbms_output.put_line(v_array(i));
EXCEPTION
WHEN NO_DATA_FOUND THEN
dbms_output.put_line('ELEMENTO i=' || i || ' no existe');
END;
exit when i=1000;
I:= I+1;
END LOOP;
END;
/
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment