power_number_1

PHOTO EMBED

Sun May 26 2024 17:45:31 GMT+0000 (Coordinated Universal Time)

Saved by @signup

CREATE OR REPLACE FUNCTION power(x IN NUMBER, n IN NUMBER) RETURN NUMBER IS
  result NUMBER := 1; -- Variable to store the result
  i NUMBER := 0; -- Loop counter
BEGIN
        FOR i IN 1..n LOOP
      result := result * x;
    END LOOP;
    RETURN result;
END;
/

declare 
 a integer:=&a;
  b integer:=&b;
begin
    
  dbms_output.put_line('factorial :'||power(a,b));
end;
/
content_copyCOPY