On Mon, Feb 24, 2014 at 10:27 PM, Jon Hough <jgho...@outlook.com> wrote:
> As a beginner in J, I am attempting to get a footing in tacit verbs.Lots > of things still confuse me, so I want to go through my trial-and-error > working, and hopefully, if someone has the time, they can explain some > things to me. > First I wanted to find the largest prime divisor of a given number > (integer). I can output that fairly quickly after rummaging around the J > dictionary: > Hi Jon, I think the other replies cover your questions, but I wanted to include an alternate implementation that I found simpler: largestPrimeDivisor=: >./ @: q: "0 largestPrimeDivisor (2 34 233 17 23) 2 17 233 17 23 I use "0 to force a rank zero (operate on each item). You can also do this in this case: largestPrimeDivisor=: >./ @ q: largestPrimeDivisor (2 34 233 17 23) 2 17 233 17 23 Because the rank of >./ and q: are 0 I liked the usage of >./ @ q: because I think it's more in line with the english definition of what you are looking for. "Find the max of the prime factors", even if it doesn't perform as well as p., which I didn't test ---------------------------------------------------------------------- For information about J forums see http://www.jsoftware.com/forums.htm