Hi list, I have an elementary question for you.
I have created Euler's Totient function with the following verb totient=: [: +/ 1 = ] +. i. totient 7 6 totient"0 >: i.10 1 1 2 2 4 2 6 4 6 4 I am interested in re-writing the verb to use conjunctions (just as a practice with J). So far, I have only come up with t=: =&[EMAIL PROTECTED] i. t 7 0 1 1 1 1 1 1 but I am having trouble summing the results t2=: +/ =&[EMAIL PROTECTED] i. t2 7 0 1 1 1 1 1 1 +/ t2 7 NB. Correct answer, but undesired implementation 6 I did managed to create a verb that gave me the correct answer, but it was because I tried some trial and error until it was correct, consequently I don't know why it returns a correct result t3=: [: +/ +/ =&[EMAIL PROTECTED] i. NB. Correct answer, but performed trial and error t3 7 6 Can someone please write how you would create Euler's Totient function in J? Thanks ---------------------------------------------------------------------- For information about J forums see http://www.jsoftware.com/forums.htm
