Here's my new, repaired 'almost prime' monadic function. It finds integers
with just two prime factors (not counting 1 or the integer), then excludes
integers with duplicated prime factors:
ap=:3 :'b#~-.+./"1]0=~."1 q:b=.a#~2=>#each q:each a=.1+i.y'
ap 20
6 10 14 15
ap 60
6 10 14 15 21 22 26 33 34 35 38 39 46 51 55 57 58
NB. Find the prime factors of each of the integers found by ap. (there
should be only 2 prime factors, and both should be unique)
{q:6 10 14 15 21 22 26 33 34 35 38 39 46 51 55 57 58
┌───┬───┬───┬───┬───┬────┬────┬────┬────┬───┬────┬────┬────┬────┬────┬────┬────┐
│2 3│2 5│2 7│3 5│3 7│2 11│2 13│3 11│2 17│5 7│2 19│3 13│2 23│3 17│5 11│3
19│2 29│
└───┴───┴───┴───┴───┴────┴────┴────┴────┴───┴────┴────┴────┴────┴────┴────┴────┘
_10{.ap 2025
1981 1982 1983 1985 1991 1994 2005 2018 2019 2021
NB. Check prime factors again:
{q:1981 1982 1983 1985 1991 1994 2005 2018 2019 2021
┌─────┬─────┬─────┬─────┬──────┬─────┬─────┬──────┬─────┬─────┐
│7 283│2 991│3 661│5 397│11 181│2 997│5 401│2 1009│3 673│43 47│
└─────┴─────┴─────┴─────┴──────┴─────┴─────┴──────┴─────┴─────┘
Skip
Skip Cave
Cave Consulting LLC
On Mon, Dec 31, 2018 at 9:53 PM Skip Cave <[email protected]> wrote:
> Bernie,
>
> Here's a monadic function that does the job:
>
> ap =. 3 :'a#~2=+/"1]0<~."1 q:a=.1+i.y'
>
>
> ap 20
>
> 6 10 12 14 15 18 20
>
> ap 100
>
> 6 10 12 14 15 18 20 21 22 24 26 28 33 34 35 36 38 39 40 44 45 46 48 50 51
> 52 54 55 56 57 58 62 63 65 68 69 72 74 75 76 77 80 82 85 86 87 88 91 92 93
> 94 95 96 98 99 100
>
> Last ten 'almost primes' through 2030:
>
> _10{.ap 2030
>
> 2007 2008 2009 2012 2018 2019 2021 2023 2025 2026
>
>
> Skip Cave
> Cave Consulting LLC
>
>
> On Mon, Dec 31, 2018 at 8:23 PM Bernie Eckhart <
> [email protected]> wrote:
>
>> 1, 3, 673, 2019
>>
>> 4 factors is almost a prime.
>>
>> Let's denote only 4 factor numbers like 2019, i.e. every factor is a
>> unique
>> integer that occurs only once, as "almost a prime" number.
>>
>> A problem is to compute efficiently all "almost a prime" numbers between 1
>> and any given prime number.
>>
>> Almost certainly a waste of time unless some pattern might be discovered
>> that allows one to predict and compute primes faster than other methods.
>>
>> I have no idea where to begin because I am not a mathematician and because
>> I am very new to J.
>>
>> HAPPY 2019!
>> ----------------------------------------------------------------------
>> For information about J forums see http://www.jsoftware.com/forums.htm
>
>
----------------------------------------------------------------------
For information about J forums see http://www.jsoftware.com/forums.htm