Oracle FAQ Your Portal to the Oracle Knowledge Grid
HOME | ASK QUESTION | ADD INFO | SEARCH | E-MAIL US
 

Home -> Community -> Mailing Lists -> Oracle-L -> Re: Just for fun

Re: Just for fun

From: Anthony Wilson <amwilson_at_iinet.net.au>
Date: Sun, 6 Nov 2005 21:30:13 +0800
Message-ID: <20051106133013.GA501@iinet.net.au>


On Sat, Nov 05, 2005 at 04:51:26PM, t_adolph_at_hotmail.com wrote:
> Hi all,
>
> Its Saturday afternoon, its raining and the rugby doesn't start for a while, so....
>
> create or replace procedure circle is
> pi constant number(5,3) := 3.142;

I believe it's because you are using a constant for pi. Maybe this code will help:

select n terms
, sqrt(6*(

    sum (1 / power(n, 2)) over (

      order by n
      rows between unbounded preceding and current row
    )
  )
) approx1
, 4 * (
  sum(decode(mod(n, 4), 1, (1/(2*n-1)), 2, (1/(2*n-1)), (-1/(2*n-1)))) over (     order by n

        rows between unbounded preceding and current row   )
) / sqrt(2) approx2
, 2*exp(sum(ln(power(2*n, 2) / ((2*n-1)*(2*n+1)))) over (   order by n
  rows between unbounded preceding and current row )) approx3
from (
  select level n
  from dual
  connect by level <= &terms
)
/

Yep, I had a rainy weekend too... :-)

cheers,
Anthony

-- 
Anthony Wilson


-- http://www.freelists.org/webpage/oracle-l

Received on Sun Nov 06 2005 - 07:33:02 CST

Original text of this message

HOME | ASK QUESTION | ADD INFO | SEARCH | E-MAIL US