Run Code
|
API
|
Code Wall
|
Misc
|
Feedback
|
Login
|
Theme
|
Privacy
|
Patreon
replace each prime by next prime in prime factorization of n excluding the first occurance
DECLARE n int := 45; type a is varray(1000) of int; prime a := a(); c int; ans int:=1; pt int; flag boolean:=false; function isprime(x int) return boolean as z boolean; begin if x<=1 then return false; end if; if x=2 then return true; end if; for i in 2 .. x-1 loop if mod(x,i) = 0 then return false; end if; end loop; return true; end; begin --dbms_output.put_line(num.count); c:=0; for i in 1 .. 1000 loop if isprime(i) = true then c:=c+1; prime.extend(); prime(c):= i; end if; end loop; for i in 1 .. c loop flag :=false; while mod(n,prime(i)) = 0 loop if flag=false then flag:=true; pt:=i; ans:=ans*prime(pt); n:=n/prime(i); CONTINUE; end if; pt:=mod(i+1,c); if pt=0 then pt:=c; end if; ans:=ans*prime(pt); n:=n/prime(i); end loop; end loop; dbms_output.put_line(ans); end;
run
|
edit
|
history
|
help
0
cursor
neha
alle angemeldeten Benutzer können eine gegebene aktion ausgeben ( im Web )
DBMS
display table 5 for using for loop
addition
Oracle Sandbox: Dog Data
DEMO.CUSTOMER
Cursor Employee Table. [Table create, insert and display]
Srinivas