Re: Seeking recursive solution to replace nested for-loops

From: Niall Litchfield <n-litchfield_at_audit-commission.gov.uk>
Date: Tue, 2 Mar 2004 09:12:40 -0000
Message-ID: <40445009$0$22393$ed9e5944_at_reading.news.pipex.net>


if it really is part of a larger assignment stick it in a package.

-- 
Niall Litchfield
Oracle DBA
Audit Commission UK
"Dave" <davidr21_at_hotmail.com> wrote in message
news: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
>
> How about this?
>
> create or replace function factorial(p_number in number) return number
> is
> begin
> if p_number = 1
> then
> return 1;
> else
> return factorial(p_number-1) * p_number;
> end if;
> end;
> /
>
> 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;
> /
>
> SQL> select bd(16, 4) from dual;
>
> BD(16,4)
> ----------
> 1820
>
> Dave
Received on Tue Mar 02 2004 - 10:12:40 CET

Original text of this message