Skip to main content
Commonmark migration
Source Link

#APL(NARS) 41 chars, 82 bytes

APL(NARS) 41 chars, 82 bytes

{(1=≢∪+/¨{v=⍵⊃v}¨⍳≢v)∧(1↓w)≡¯1↓1πw←∪v←π⍵}

{π⍵} is the function factorization of argument ⍵ in the list of prime factors (repeat if one prime appear more time);
{1π⍵} is the function next prime (note that in this case its argument is not a scalar but one array of integers). test:

  h←{(1=≢∪+/¨{v=⍵⊃v}¨⍳≢v)∧(1↓w)≡¯1↓1πw←∪v←π⍵}
  (2..30)/⍨h¨2..30
2 3 4 5 6 7 8 9 11 13 15 16 17 19 23 25 27 29 30 
  h¨27000 456533 72 10000000
1 1 0 0 

#APL(NARS) 41 chars, 82 bytes

{(1=≢∪+/¨{v=⍵⊃v}¨⍳≢v)∧(1↓w)≡¯1↓1πw←∪v←π⍵}

{π⍵} is the function factorization of argument ⍵ in the list of prime factors (repeat if one prime appear more time);
{1π⍵} is the function next prime (note that in this case its argument is not a scalar but one array of integers). test:

  h←{(1=≢∪+/¨{v=⍵⊃v}¨⍳≢v)∧(1↓w)≡¯1↓1πw←∪v←π⍵}
  (2..30)/⍨h¨2..30
2 3 4 5 6 7 8 9 11 13 15 16 17 19 23 25 27 29 30 
  h¨27000 456533 72 10000000
1 1 0 0 

APL(NARS) 41 chars, 82 bytes

{(1=≢∪+/¨{v=⍵⊃v}¨⍳≢v)∧(1↓w)≡¯1↓1πw←∪v←π⍵}

{π⍵} is the function factorization of argument ⍵ in the list of prime factors (repeat if one prime appear more time);
{1π⍵} is the function next prime (note that in this case its argument is not a scalar but one array of integers). test:

  h←{(1=≢∪+/¨{v=⍵⊃v}¨⍳≢v)∧(1↓w)≡¯1↓1πw←∪v←π⍵}
  (2..30)/⍨h¨2..30
2 3 4 5 6 7 8 9 11 13 15 16 17 19 23 25 27 29 30 
  h¨27000 456533 72 10000000
1 1 0 0 
added 80 characters in body
Source Link
user58988
user58988

#APL(NARS) 41 chars, 82 bytes

{(1=≢∪+/¨{v=⍵⊃v}¨⍳≢v)∧(1↓w)≡¯1↓1πw←∪v←π⍵}

{π⍵} is the function factorization of argument ⍵ in the list of prime factors (repeat if one prime appear more time);
{1π⍵} is the function next prime (note that in this case its argument is not a scalar but one array of integers). test:

  h←{(1=≢∪+/¨{v=⍵⊃v}¨⍳≢v)∧(1↓w)≡¯1↓1πw←∪v←π⍵}
  (2..30)/⍨h¨2..30
2 3 4 5 6 7 8 9 11 13 15 16 17 19 23 25 27 29 30 
  h¨27000 456533 72 10000000
1 1 0 0 

#APL(NARS) 41 chars, 82 bytes

{(1=≢∪+/¨{v=⍵⊃v}¨⍳≢v)∧(1↓w)≡¯1↓1πw←∪v←π⍵}

{π⍵} is the function factorization of argument ⍵ in the list of prime factors (repeat if one prime appear more time);
{1π⍵} is the function next prime. test:

  h←{(1=≢∪+/¨{v=⍵⊃v}¨⍳≢v)∧(1↓w)≡¯1↓1πw←∪v←π⍵}
  (2..30)/⍨h¨2..30
2 3 4 5 6 7 8 9 11 13 15 16 17 19 23 25 27 29 30 
  h¨27000 456533 72 10000000
1 1 0 0 

#APL(NARS) 41 chars, 82 bytes

{(1=≢∪+/¨{v=⍵⊃v}¨⍳≢v)∧(1↓w)≡¯1↓1πw←∪v←π⍵}

{π⍵} is the function factorization of argument ⍵ in the list of prime factors (repeat if one prime appear more time);
{1π⍵} is the function next prime (note that in this case its argument is not a scalar but one array of integers). test:

  h←{(1=≢∪+/¨{v=⍵⊃v}¨⍳≢v)∧(1↓w)≡¯1↓1πw←∪v←π⍵}
  (2..30)/⍨h¨2..30
2 3 4 5 6 7 8 9 11 13 15 16 17 19 23 25 27 29 30 
  h¨27000 456533 72 10000000
1 1 0 0 
deleted 14 characters in body
Source Link
user58988
user58988

#APL(NARS) 4941 chars, 9882 bytes

{k←≢v←π⍵⋄p←1πw←∪v⋄((1↓w)≡¯1↓p)∧1=≢∪+1=≢∪+/¨{v=⍵⊃v}¨⍳k¨⍳≢v)∧(1↓w)≡¯1↓1πw←∪v←π⍵}

{π⍵} is the function factorization of argument ⍵ in the list of prime factors (repeat if one prime appear more time);
{1π⍵} is the function next prime. test:

  h←{k←≢v←π⍵⋄p←1πw←∪v⋄((1↓w)≡¯1↓p)∧1=≢∪+1=≢∪+/¨{v=⍵⊃v}¨⍳k¨⍳≢v)∧(1↓w)≡¯1↓1πw←∪v←π⍵}
  (2..30)/⍨h¨2..30
2 3 4 5 6 7 8 9 11 13 15 16 17 19 23 25 27 29 30 
  h¨27000 456533 72 10000000
1 1 0 0 

#APL(NARS) 49 chars, 98 bytes

{k←≢v←π⍵⋄p←1πw←∪v⋄((1↓w)≡¯1↓p)∧1=≢∪+/¨{v=⍵⊃v}¨⍳k}

{π⍵} is the function factorization of argument ⍵ in the list of prime factors (repeat if one prime appear more time);
{1π⍵} is the function next prime. test:

  h←{k←≢v←π⍵⋄p←1πw←∪v⋄((1↓w)≡¯1↓p)∧1=≢∪+/¨{v=⍵⊃v}¨⍳k}
  (2..30)/⍨h¨2..30
2 3 4 5 6 7 8 9 11 13 15 16 17 19 23 25 27 29 30 
  h¨27000 456533 72 10000000
1 1 0 0 

#APL(NARS) 41 chars, 82 bytes

{(1=≢∪+/¨{v=⍵⊃v}¨⍳≢v)∧(1↓w)≡¯1↓1πw←∪v←π⍵}

{π⍵} is the function factorization of argument ⍵ in the list of prime factors (repeat if one prime appear more time);
{1π⍵} is the function next prime. test:

  h←{(1=≢∪+/¨{v=⍵⊃v}¨⍳≢v)∧(1↓w)≡¯1↓1πw←∪v←π⍵}
  (2..30)/⍨h¨2..30
2 3 4 5 6 7 8 9 11 13 15 16 17 19 23 25 27 29 30 
  h¨27000 456533 72 10000000
1 1 0 0 
Source Link
user58988
user58988
Loading