[Jprogramming] Fitting factors of positive integers
Roger Hui
rhui000 at shaw.ca
Tue Jan 8 00:24:13 HKT 2008
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 <holmeswn at yahoo.com.au>
Date: Sunday, January 6, 2008 21:12
Subject: [Jprogramming] Fitting factors of positive integers
To: programming at jsoftware.com
> 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 ?
...
More information about the Programming
mailing list