Skip to main content
added 362 characters in body
Source Link
Galen Ivanov
  • 21.2k
  • 3
  • 24
  • 61

J, 16 bytes

Big thanks to FrownyFrog for -8 bytes!

(=&#+/\=@#])_&q:

Try it online!

My old solution:

J, 24 bytes

[:(1=[:#@~.{.@I.}.])_&q:

Try it online!

Explanation:

_&q: prime exponents

{.@I.}.] removes the leading zeros by finding the first non-zero element:

     }.   drop
       ]  from the list of exponents
{.@       as much items as the first of the 
   I.     indices of non-zero elements

1=[:#@~. tests if all remaining numbers are equal:

  [:#@~.  finds the length of the list after removing the duplicates
1=        is it 1?

J, 24 bytes

[:(1=[:#@~.{.@I.}.])_&q:

Try it online!

Explanation:

_&q: prime exponents

{.@I.}.] removes the leading zeros by finding the first non-zero element:

     }.   drop
       ]  from the list of exponents
{.@       as much items as the first of the 
   I.     indices of non-zero elements

1=[:#@~. tests if all remaining numbers are equal:

  [:#@~.  finds the length of the list after removing the duplicates
1=        is it 1?

J, 16 bytes

Big thanks to FrownyFrog for -8 bytes!

(=&#+/\=@#])_&q:

Try it online!

My old solution:

J, 24 bytes

[:(1=[:#@~.{.@I.}.])_&q:

Try it online!

Explanation:

_&q: prime exponents

{.@I.}.] removes the leading zeros by finding the first non-zero element:

     }.   drop
       ]  from the list of exponents
{.@       as much items as the first of the 
   I.     indices of non-zero elements

1=[:#@~. tests if all remaining numbers are equal:

  [:#@~.  finds the length of the list after removing the duplicates
1=        is it 1?
deleted 15 characters in body
Source Link
Galen Ivanov
  • 21.2k
  • 3
  • 24
  • 61

J, 2524 bytes

[:(1=#@~1=[:#@~.)@({.@I.}.])_&q:

Try it online!

Explanation:

_&q: prime exponents

({.@I.}.]) removes the leading zeros by finding the first non-zero element:

      }.   drop
        ]  from the list of exponents
{.@        as much items as the first of the 
   I.      indices of non-zero elements

@ and

(1=#@~1=[:#@~.) tests if all remaining numbers are equal by:

  [:#@~.   finds the length of the list after removing the duplicates
1=        is it 1?

Try it online!

J, 25 bytes

[:(1=#@~.)@({.@I.}.])_&q:

Explanation:

_&q: prime exponents

({.@I.}.]) removes the leading zeros by finding the first non-zero element:

      }.   drop
        ]  from the list of exponents
{.@        as much items as the first of the 
   I.      indices of non-zero elements

@ and

(1=#@~.) tests if all remaining numbers are equal by:

  #@~.   finds the length of the list after removing the duplicates
1=       is it 1?

Try it online!

J, 24 bytes

[:(1=[:#@~.{.@I.}.])_&q:

Try it online!

Explanation:

_&q: prime exponents

{.@I.}.] removes the leading zeros by finding the first non-zero element:

     }.   drop
       ]  from the list of exponents
{.@       as much items as the first of the 
   I.     indices of non-zero elements

1=[:#@~. tests if all remaining numbers are equal:

  [:#@~.  finds the length of the list after removing the duplicates
1=        is it 1?
Source Link
Galen Ivanov
  • 21.2k
  • 3
  • 24
  • 61

J, 25 bytes

[:(1=#@~.)@({.@I.}.])_&q:

Explanation:

_&q: prime exponents

({.@I.}.]) removes the leading zeros by finding the first non-zero element:

      }.   drop
        ]  from the list of exponents
{.@        as much items as the first of the 
   I.      indices of non-zero elements

@ and

(1=#@~.) tests if all remaining numbers are equal by:

  #@~.   finds the length of the list after removing the duplicates
1=       is it 1?

Try it online!