Thanks Rob, Bo, & Mike for your enlightening answers.
So now I have a similar question on a simpler data set:
Given:
g=.4 5$ 1 2 3 4 5 2 3 4 5 6 5 3 7 1 8 3 8 6 1 5
g
1 2 3 4 5
2 3 4 5 6
5 3 7 1 8
3 8 6 1 5
How do I find the common integers in g across all rows (the answer is 3 5)?
Rob's scheme works if I box g:
in each/ ~. each {g
┌───┐
│3 5│
└───┘
Or even simpler:
in each/ {g
┌───┐
│3 5│
└───┘
I'm not sure how to apply Bo's +./ scheme to g:
+./g
1 1 1 1 1
Same for Mike's ix verb:
ix =: ([ -. -.)
ix g
1 2 3 4 5
2 3 4 5 6
5 3 7 1 8
3 8 6 1 5
Skip
On Tue, Oct 23, 2018 at 1:31 AM Skip Cave <[email protected]> wrote:
> Given the integers: 1998 2997 3996 4995 5994 6993 7992 8991
> Find the common prime factors in all of these integers.
>
> Obviously we can find the prime factors of each of the integers:
>
> q: 1998 2997 3996 4995 5994 6993 7992 8991
>
> 2 3 3 3 37 0 0
>
> 3 3 3 3 37 0 0
>
> 2 2 3 3 3 37 0
>
> 3 3 3 5 37 0 0
>
> 2 3 3 3 3 37 0
>
> 3 3 3 7 37 0 0
>
> 2 2 2 3 3 3 37
>
> 3 3 3 3 3 37 0
>
>
> What J expression will find the common factors in all 6 of these integers?
>
> (the result of the expression should be that there are two common factors
> - 3 & 37)
>
> Skip
>
>
----------------------------------------------------------------------
For information about J forums see http://www.jsoftware.com/forums.htm