Re: Seeking recursive solution to replace nested for-loops
Date: 1 Mar 2004 19:53:42 -0800
Message-ID: <8244b794.0403011953.54f798d6_at_posting.google.com>
mromano_at_sensis.com (Michelle Romano) wrote in message news:<aaba7f35.0403010548.61f136b6_at_posting.google.com>...
> "Ryan" <rgaffuri_at_cox.net> wrote in message news:<GOxZb.9939$23.8686_at_lakeread04>...
> > 1. the answer to this is on the internet. though not in pl/sql, but you can
> > translate
> > 2. This is probably a homework assignment.
> >
>
> Ryan,
>
> I have seen a few related solutions in C++, but they don't seem very
> straightforward to translate. I don't have very much C++ background.
> Also, for your information, this is not a homework assignment. It is
> one small piece of a larger task I am working on for my job.
>
> Michelle
[Quoted] How about this?
[Quoted] [Quoted] create or replace function factorial(p_number in number) return number
is
begin
if p_number = 1
then
return 1;
else
[Quoted] return factorial(p_number-1) * p_number;
end if;
end;
/
[Quoted] create or replace function bd(p_n in number, p_k in number) return number
is
begin
return factorial(p_n) / ( factorial(p_k) * factorial(p_n-p_k) );
end;
/
[Quoted] SQL> select bd(16, 4) from dual;
BD(16,4)
1820
Dave Received on Tue Mar 02 2004 - 04:53:42 CET