Bill Allombert on Fri, 04 Dec 2009 00:27:46 +0100 |
[Date Prev] [Date Next] [Thread Prev] [Thread Next] [Date Index] [Thread Index]
Re: Getting more than one value out of a function |
On Thu, Dec 03, 2009 at 01:18:35PM -0800, curiousity wrote: > > Hi. > How do I tell PARI I want to repeatedly evaluate a function to get out more > than one value? > > I've entered: n=0;n=n+1;r=prod(a=1,n-1,1-1/prime(a))/prime(n) . > > PARI spits out 1/2, but I want 1/2, 1/6, 2/30, 8/210, 48/2310, 480/30030, > etc. > > I've been poking through the tutorial and online help, but most of it is > aimed at an audience that is more math-competent and computer-savvy than I. > If anyone is willing to take the time to post a step-by-step text > description, it would really help me get going. Use the vector function: ? vector(10,n,prod(a=1,n-1,1-1/prime(a))/prime(n)) %4 = [1/2, 1/6, 1/15, 4/105, 8/385, 16/1001, 192/17017, 3072/323323, 55296/7436429, 110592/19605131] or use for: ? for(n=1,20,print(prod(a=1,n-1,1-1/prime(a))/prime(n))) 1/2 1/6 1/15 ... Cheers, Bill.