Skip to main content
We’ve updated our Terms of Service. A new AI Addendum clarifies how Stack Overflow utilizes AI interactions.
Code Golf

Return to Answer

Left the parentheses in
Source Link
user
  • 457
  • 2
  • 21
  • 71

APL (Dyalog Unicode), 108 bytes

∨/1~⍨(⊢∨⍳)1~⍨⊢∨⍳

Try it online! Try it online!

Outputs 1 if it isn't almost-prime, some other positive integer otherwise.

∨/1~⍨(⊢∨⍳)1~⍨⊢∨⍳
 (⊢∨⍳) ⍝ All divisors
 1~⍨ ⍝ Remove 1
∨/ ⍝ GCD

APL (Dyalog Unicode), 10 bytes

∨/1~⍨(⊢∨⍳)

Try it online!

Outputs 1 if it isn't almost-prime, some other positive integer otherwise.

∨/1~⍨(⊢∨⍳)
 (⊢∨⍳) ⍝ All divisors
 1~⍨ ⍝ Remove 1
∨/ ⍝ GCD

APL (Dyalog Unicode), 8 bytes

∨/1~⍨⊢∨⍳

Try it online!

Outputs 1 if it isn't almost-prime, some other positive integer otherwise.

∨/1~⍨⊢∨⍳
 ⊢∨⍳ ⍝ All divisors
 1~⍨ ⍝ Remove 1
∨/ ⍝ GCD
deleted 716 characters in body
Source Link
user
  • 457
  • 2
  • 21
  • 71

APL (Dyalog Unicode), 2210 bytes

3>∘(≢∪)⊢∨/1~⍨(×ばつ⊢∨⍳)1↓⍳

Try it online! Try it online!

If a non-consistent output is okay,Outputs 1 if it can be 18 bytes (1 or 2 means it'sisn't almost prime-prime, anything greater than that means it isn't):

≢∘∪⊢(×ばつ⊢)1↓⍳

Try it online! some other positive integer otherwise.

3>∘(≢∪)⊢∨/1~⍨(×ばつ⊢∨⍳)1↓⍳
 (×ばつ⊢∨⍳)1↓⍳PrimeAll factorizationdivisors
 1~⍨ ⍝ Remove duplicates
 ≢  ⍝ Length1
3> ∨/Is it less than 3?GCD

APL (Dyalog Unicode), 22 bytes

3>∘(≢∪)⊢(×ばつ)1↓⍳

Try it online!

If a non-consistent output is okay, it can be 18 bytes (1 or 2 means it's almost prime, anything greater than that means it isn't):

≢∘∪⊢(×ばつ⊢)1↓⍳

Try it online!

3>∘(≢∪)⊢(×ばつ)1↓⍳
 (×ばつ)1↓⍳Prime factorization
  ⍝ Remove duplicates
 ≢  ⍝ Length
3> Is it less than 3?

APL (Dyalog Unicode), 10 bytes

∨/1~⍨(⊢∨⍳)

Try it online!

Outputs 1 if it isn't almost-prime, some other positive integer otherwise.

∨/1~⍨(⊢∨⍳)
 (⊢∨⍳) ⍝ All divisors
 1~⍨ ⍝ Remove 1
∨/GCD
Source Link
user
  • 457
  • 2
  • 21
  • 71

APL (Dyalog Unicode), 22 bytes

3>∘(≢∪)⊢(×ばつ⊢)1↓⍳

Try it online!

If a non-consistent output is okay, it can be 18 bytes (1 or 2 means it's almost prime, anything greater than that means it isn't):

≢∘∪⊢(×ばつ⊢)1↓⍳

Try it online!

3>∘(≢∪)⊢(×ばつ⊢)1↓⍳
 ⊢(×ばつ⊢)1↓⍳ ⍝ Prime factorization
 ∪ ⍝ Remove duplicates
 ≢ ⍝ Length
3> ⍝ Is it less than 3?

AltStyle によって変換されたページ (->オリジナル) /