f=: */ .^"1 (#: i.@(*/))@:>: factors=: f/@(__&q:) factors 160 1 5 2 10 4 20 8 40 16 80 32 160 factors 144 1 3 9 2 6 18 4 12 36 8 24 72 16 48 144 factors 97 1 97 factors 1 1
Or, to name a well-known subexpression used therein, odometer=: #: i.@(*/) f=: */ .^"1 odometer@:>: ----- Original Message ----- From: neville holmes <[EMAIL PROTECTED]> Date: Sunday, January 6, 2008 21:12 Subject: [Jprogramming] Fitting factors of positive integers To: [email protected] > I was trying to put myself to sleep last night by > working out (tacit) ways to list the distinct factors > of positive integers. Is there a better way than > simply sieving through all the candidates less > than or equal to the square root of the number ? ... ---------------------------------------------------------------------- For information about J forums see http://www.jsoftware.com/forums.htm
