Student Support Forum: 'Problems with a Function' topicStudent Support Forum > General > Archives > "Problems with a Function"

 Next Comment > Help | Reply To Topic
 Author Comment/Response Justin Paston-Cooper 01/22/07 12:42pm Hello. I have had some problems with a function that I have defined. I am getting a number returned when a list should be returned. What I want to do is get a list of all the primes under 1000000. I am trying to do this by testing whether the prime is above 1000000 and if it is, returning y, else calling the function again with the next x and the current prime prepended to the accumulated list. Here is the code: Loopy[x_, y_] := prime = Prime[x]; Print[Head[y]]; If[prime > 1000000, y, Loopy[x + 1, Prepend[y, prime]]]; Thanks for any help, in advance. URL: ,

 Subject (listing for 'Problems with a Function') Author Date Posted Problems with a Function Justin Pasto... 01/22/07 12:42pm Re: Problems with a Function yehuda ben-s... 01/23/07 01:05am Re: Problems with a Function Justin Pasto... 01/23/07 11:01am
 Next Comment > Help | Reply To Topic