Spot the non-deliberate editing error!
M
On 14/08/2018 16:16, Mike Day wrote:
How about these snapshots?
q =: 21, 38, 55, 106
}.+/\inv q NB. 1st differences
21 17 17 51
+./}.+/\inv q NB. gcd of 1st diffs
17
NB. or
2 -/\ q
_17 _17 _51
+./2 -/\ q
17
17|q NB. So, what is the required offset?
4 4 4 4
17%~ q-4 NB. what are the required factors?
1 2 3 6
Mike
On 14/08/2018 07:07, Skip Cave wrote:
Attempting to solve the following Quora problem:
What number must be subtracted from 21, 38, 55, and 106 each so that the
remainders (technically differences) are proportional?
Subtract the integers 0-9 from all four integers in the problem. Then find
the prime factors of each set of four integers. Finally look for columns
that have common factors in all four results:
]b=.q: each 21 38 55 106-/a=.i.10
┌────┬───────┬────────┬──────┬──────┬───────┬─────────┬─────────┬─────┬─────┐
│3 7 │2 2 5 │19 │2 3 3 │17 │2 2 2 2│3 5 │2 7 │13 │2 2 3│
├────┼───────┼────────┼──────┼──────┼───────┼─────────┼─────────┼─────┼─────┤
│2 19│37 │2 2 3 3 │5 7 │2 17 │3 11 │2 2 2 2 2│31 │2 3 5│29 │
├────┼───────┼────────┼──────┼──────┼───────┼─────────┼─────────┼─────┼─────┤
│5 11│2 3 3 3│53 │2 2 13│3 17 │2 5 5 │7 7 │2 2 2 2 3│47 │2 23 │
├────┼───────┼────────┼──────┼──────┼───────┼─────────┼─────────┼─────┼─────┤
│2 53│3 5 7 │2 2 2 13│103 │2 3 17│101 │2 2 5 5 │3 3 11 │2 7 7│97 │
└────┴───────┴────────┴──────┴──────┴───────┴─────────┴─────────┴─────┴─────┘
Now how can I write a J function that lists the column index in this array
where all four sets of factors have at least one common factor? Spoiler -
In the example, the 5th set (column index 4) has a common factor of 17.
Skip
Skip Cave
Cave Consulting LLC
----------------------------------------------------------------------
For information about J forums seehttp://www.jsoftware.com/forums.htm
---
This email has been checked for viruses by Avast antivirus software.
https://www.avast.com/antivirus
----------------------------------------------------------------------
For information about J forums see http://www.jsoftware.com/forums.htm