Bill Allombert on Wed, 22 Mar 2023 09:49:49 +0100
|
[Date Prev] [Date Next] [Thread Prev] [Thread Next] [Date Index] [Thread Index]
Re: defining a recurrence
|
- To: pari-users@pari.math.u-bordeaux.fr
- Subject: Re: defining a recurrence
- From: Bill Allombert <Bill.Allombert@math.u-bordeaux.fr>
- Date: Wed, 22 Mar 2023 09:48:22 +0100
- Arc-authentication-results: i=1; smail; arc=none
- Arc-message-signature: i=1; a=rsa-sha256; d=math.u-bordeaux.fr; s=openarc; t=1679474899; c=relaxed/relaxed; bh=FadHJ1QbfpFXLORv2JfS4ZgDdH1n0IwppFeHBjWabTc=; h=DKIM-Signature:Date:From:To:Subject:Message-ID:Mail-Followup-To: References:MIME-Version:Content-Type:Content-Disposition: In-Reply-To; b=imuPwMqj9CgOmDHExYK2BuUkd506YPr/6jtnrX2oyuqZfvPhpHXd/nRVXRDLCyu71dWjSRl8mS2yerjOaiYdkzi6d+Dl3iYnNahloubVZhu8gzAsVknvIHosZ2wp7yTB0DI+1OhFDX2z85sqfJMKoNQoJXg5jU+pAfWljibutMJOAerULn/24wN70/cQx7ZMelNud0xqYLyG7yLklklCTNIKrruc32m60GzHpNRLNOvhIuL+gCeoXxXlukvEZVE8rkcIKTFmivieYi3punvGsdjVVWjDmFPhab7ymZQjHxTZTNFn6fyzLuBAKlIjp9/hlqP1YfKXwQ3ugy88EzEJiK2apdST8UR0I7tjwXWcWwb8sseUe3k0qT7XAsJXgsLyrRUIugy0DIp/3FOj3U22N9VONtfMomrLyYOtYtF+mmV5/F40zBBetJv/xE0NBmf8tpuFyMy9HiPid2w5rVZtvmORIRu2pivxCsUcFK19BPzV0IJ1aW4TepwSrejf6kYmVwj1VWvbWkhEHVTA2hYydBzZPg6xAP0/w75XuT7IU7ogXVYLGskMglCw/DKKhHGRT5KydCgDYl6zZMZaHpWLf05ApjSdINLCDvUd2EgDSH8M3Gwz8Fm2SJTbg3gjhXX4vA4Htfyr6jmXR9RMPGvygNssV8UVxCPOkoJzZndAcn8=
- Arc-seal: i=1; a=rsa-sha256; d=math.u-bordeaux.fr; s=openarc; t=1679474899; cv=none; b=PdegQqlOys6o3mGl3J78go7hBIu3NPBpfygRietVvXOoXJaredC1rmgu02ypEuFOz1mScTny6Lh+e5Sxl7wE/d2trHvwVkooh1mU9/2PKa8A3tFRj/c7QdfOJWxi4Z24XmaJp79tzuUv0AluMBetS2Z98x0hK4UHsV3DPp1P4KHiCQzqIur3cP8PJnPuKPXAAv+oQ2q87B4qVjxs8QyhyR6NP3XotMr0Fdk+i5o3wXOrr2vfClgbKZ/7D9GHUzBnp/dlQY3SN/hvyD8und66j24onBv+9wSsFFEQ5BjKfmqmQSa8+Mhwh19kGA8S6wwsKS5bwzONhuAQVw8ZqrltaAk1BAx5myYMTliEd1vE/KNWmgISghX93+jyUGgKqaL4du+pRkrD9yLzFZwgdqV3NsMaDbSnW+CoU82tJOEQuct+leBTRkpNC8Ko7JJ/1pDLkJZxTcRzp54tsuqvb8ln1N/cMgFf+BhdMd3WtSbLeR0UREo6uS6l/3BHuh5nZs0s1LWaOgAJrjXBHTVFDdXBNY7eAMUJcBe3w63NI+AiVD5jMgwD/iUJYjlqNgsomOCFu+5Uuorp6HxSmd/0t/+A5XD20qfaobu+f4W1Nq0lBV94BSRs6O+Xw5iyQCe5oz+Q+j3xKSI+a/5pomPf7FtAX7H2gvTG5kMDbQNaFkNX7HI=
- Authentication-results: smail; arc=none
- Delivery-date: Wed, 22 Mar 2023 09:49:49 +0100
- Dkim-signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=math.u-bordeaux.fr; s=2022; t=1679474899; bh=FadHJ1QbfpFXLORv2JfS4ZgDdH1n0IwppFeHBjWabTc=; h=Date:From:To:Subject:References:In-Reply-To:From; b=FJ/47RvtB7qQItpg7tTKkwPdkMYOwz23Tp38/GilmGcMC06PBD4IW8t0jQJtIW+BA nfynqwQqRXi0ot98yfWyxMuEI4zrHdIUj3YoP3dA8oUwvuH0XqqLaO/gCans6WDLQB 5sop8l6aTcCMMt49tSeQSkDfyT7v3uJjHDiM4ZYl0VrnZMwKEXqEU7rckIPyIkGwyT zlTp1DPl68mFbHCTMg77FwiREJqgudoPXGocHn0JOnPyxhlmEklPWFp9Jov93TQTfk 1Nk/pLL6hL/sHnBBE8ow8MpiaP2fp/8tuFX7V5ZFHigvYyics/QNCkCCIXpZoY0cjS t8U39cfaDO+5LwWpUJMoOst1+YdpUDM4SH2T/3ThV3IOxf0K4EIzWczyKAZvwhes2J R7tnih+E+8DjXcer/tZv7lhkEPu8NIZ/bXPOHxhuqNv3jJkFe59uuyI50c3KTjk4bl RCYnJruzXdYthC3GlkRbBtTCBpPm9ic+ukDDi0Ctf50KYYxccf0ABlbJpgzNNj7jwh +5z/5DdPRLUOijkaeJ//p6Cc+eUKPtM1/n94N6u7b73tQBSqCHr8l2+RShIQAjvb+U MDdB2vk7BnJR22p/VOGmV0lEz21/q1bGTmiVlrctESgRZobmjL2K72hOvztUiqY7fR pxeK/cDHWlaQtNJ5jF6g74gM=
- In-reply-to: <1c5a1608-bb92-5097-b963-bf047c361de8@free.fr>
- Mail-followup-to: pari-users@pari.math.u-bordeaux.fr
- References: <1c5a1608-bb92-5097-b963-bf047c361de8@free.fr>
On Wed, Mar 22, 2023 at 02:01:52AM +0100, Jean-Luc ARNAUD wrote:
> Hi all,
>
> Looking in PariGP documentation, I don't find how to define a recurrence.
>
> For example, let say I'd like to define the Factorial function F:
>
> F(x+1)=F(x)*(x+1)
>
> F(1)=1
>
> How to define F, if possible?
You need to use the 'if' statement to separate cases:
F(x)=if(x==0, 1, F(x-1)*x);
apply(F,[1..5])
%24 = [1,2,6,24,120]
if you have an anoymous function, you can use self() to refer to itself:
apply(x->if(x==0, 1, self()(x-1)*x),[1..5])
%27 = [1,2,6,24,120]
Cheers,
Bill