oracle - pl/sql even and odd sum block -


i have pl/sql programming question: numbers between 1..50, need multiply numbers five, odd numbers 3 , find sum of numbers in result.

so had far

declare ln_num number :=0; ln_num1 number :=0; ln_num2 number :=0;  begin     in 1..50 loop          if mod(i,2) =0                     ln_num:=i*5;          elsif mod(i,2) = 1         ln_num1:=i*3;          ln_num2 := ln_num+ln_num1;         dbms_output.put_line(ln_num2);          end if;     end loop; end; 

this gives me last list of numbers need sum of of them. wondering missing , how fix this?

thanks

sql> declare   2  ln_num number :=0;   3  ln_num1 number :=0;   4  ln_num2 number :=0;   5   6  begin   7      in 1..50 loop   8   9          if mod(i,2) =0  10          ln_num:=ln_num+i*5;  -- changes  11  12          elsif mod(i,2) = 1  13          ln_num1:=ln_num1+i*3;  -- changes  14  15  16          end if;  17      end loop;  18      ln_num2 := ln_num+ln_num1;  19          dbms_output.put_line(' result ' || ln_num2);  20  21  end;  22  23  24  / result 5125  pl/sql procedure completed. 

Popular posts from this blog

c# - ODP.NET Oracle.ManagedDataAccess causes ORA-12537 network session end of file -

matlab - Compression and Decompression of ECG Signal using HUFFMAN ALGORITHM -

utf 8 - split utf-8 string into bytes in python -