Skip to main content
added 1 character in body
Source Link
Luis Mendo
  • 106.7k
  • 10
  • 139
  • 382

MATL, 4 bytes

Yf&= 
  • For almost-primes the output is a matrix containing only ones1s, which is truthy.
  • Otherwise the output is a matrix containing several ones1s and at least a zeroone 0, which is falsy.

Try it online! Or verify all test cases, including truthiness/falsihood test.

How it works

 % Implicit input Yf % Prime factors. Gives a vector with the possibly repeated prime factors &= % Matrix of all pair-wise equality comparisons % Implicit output 

MATL, 4 bytes

Yf&= 
  • For almost-primes the output is a matrix containing only ones, which is truthy.
  • Otherwise the output is a matrix containing several ones and at least a zero, which is falsy.

Try it online! Or verify all test cases, including truthiness/falsihood test.

How it works

 % Implicit input Yf % Prime factors. Gives a vector with the possibly repeated prime factors &= % Matrix of all pair-wise equality comparisons % Implicit output 

MATL, 4 bytes

Yf&= 
  • For almost-primes the output is a matrix containing only 1s, which is truthy.
  • Otherwise the output is a matrix containing several 1s and at least one 0, which is falsy.

Try it online! Or verify all test cases, including truthiness/falsihood test.

How it works

 % Implicit input Yf % Prime factors. Gives a vector with the possibly repeated prime factors &= % Matrix of all pair-wise equality comparisons % Implicit output 
deleted 2 characters in body
Source Link
Luis Mendo
  • 106.7k
  • 10
  • 139
  • 382

MATL, 4 bytes

Yf&= 
  • For almost-primes the output is a matrix containing only ones, which is truthy.
  • Otherwise the output is a matrix containing (severalseveral ones and) at least a zero, which is falsy.

Try it online! Or verify all test casesverify all test cases, including truthiness/falsihood test.

How it works

 % Implicit input Yf % Prime factors. Gives a vector with the possibly repeated prime factors &= % Matrix of all pair-wise equality comparisons % Implicit output 

MATL, 4 bytes

Yf&= 
  • For almost-primes the output is a matrix containing only ones, which is truthy.
  • Otherwise the output is a matrix containing (several ones and) at least a zero, which is falsy.

Try it online! Or verify all test cases, including truthiness/falsihood test.

How it works

 % Implicit input Yf % Prime factors. Gives a vector with the possibly repeated prime factors &= % Matrix of all pair-wise equality comparisons % Implicit output 

MATL, 4 bytes

Yf&= 
  • For almost-primes the output is a matrix containing only ones, which is truthy.
  • Otherwise the output is a matrix containing several ones and at least a zero, which is falsy.

Try it online! Or verify all test cases, including truthiness/falsihood test.

How it works

 % Implicit input Yf % Prime factors. Gives a vector with the possibly repeated prime factors &= % Matrix of all pair-wise equality comparisons % Implicit output 
Source Link
Luis Mendo
  • 106.7k
  • 10
  • 139
  • 382

MATL, 4 bytes

Yf&= 
  • For almost-primes the output is a matrix containing only ones, which is truthy.
  • Otherwise the output is a matrix containing (several ones and) at least a zero, which is falsy.

Try it online! Or verify all test cases, including truthiness/falsihood test.

How it works

 % Implicit input Yf % Prime factors. Gives a vector with the possibly repeated prime factors &= % Matrix of all pair-wise equality comparisons % Implicit output