g | x | w | all
Bytes Lang Time Link
010Uiua SBCS240201T073445Zchunes
050Regex ECMAScript or better240122T213410ZDeadcode
2875Vyxal g240117T213747Zpacman25
043Perl 5 ap240117T153821ZXcali
027Mathematica240102T125229Zpzq_alex
008APLNARS240104T211317ZRosario
003Nekomata + e230805T050829Zalephalp
043Python230728T210745Zxnor
063C230730T132705ZPeter
047Desmos230801T072946ZAiden Ch
032Ruby rprime230731T213616ZValue In
027TIBASIC TI84 Plus/Plus CE230728T160627Zjoyofori
008Brachylog230731T094256ZFatalize
021Dyalog APL230729T161824Zmitchell
002Thunno 2 G230729T155326ZThe Thon
032JavaScript230729T134346ZAkif9748
004Vyxal230729T141538Znoodle m
007Japt230728T170429ZShaggy
101Racket230728T113216ZEd The &
024R230728T094349Zpajonk
022Octave230728T111409ZLuis Men
030Arturo230728T092754Zchunes
025Charcoal230728T090345ZNeil
064Retina 0.8.2230728T085531ZNeil
018K ngn/k230728T071459ZBubbler
029Factor + math.primes.factors math.unicode230728T070619Zchunes
00305AB1E230728T070743ZKevin Cr
043Python 3230728T063503Zdingledo
008J230728T060449ZJonah
042Excel230728T062130ZJos Wool
004Jelly230728T060424ZUnrelate

Uiua SBCS, 10 bytes

/×>1⊜⧻.°/×

Try it!

Regex (ECMAScript or better), 50 bytes

^((?=(xx+?)\2+$)((?=\2+$)(?=(x+)(\4+$))\5){2,})*x$

Try it online! - ECMAScript
Try it online! - Perl
Try it online! - Java
Try it online! - Python
Try it online! - Ruby
Try it online! - PCRE
Try it online! - .NET

I adapted this on 2018-12-26, as a slight modification to the regex that matches numbers of the form \$n^k\$, where \$k\$ is a constant. In its implementation, that regex actually matches numbers that are either \$0\$ or of the form \$n^k=\prod_{i=0}^{q} p_i^{k_i}=p_0^{k_0}p_1^{k_1}p_2^{k_2}...p_q^{k_q}\$ where all \$p_m\$ are distinct primes, all \$k_m=k\$, and \$q\ge 0\$.

The only changes here, to match powerful numbers instead, are to make \$k_m\ge 2\$ (which takes 1 extra byte), and not to match \$0\$ (which saves 1 byte).

In other words, this regex works by dividing away each prime factor, from smallest to largest, asserting along the way that each distinct prime is divided away at least twice, with an end result of \$1\$.

^                     # N = input number (initial value of tail)
(                     # Loop/iterate the following:
    (?=(xx+?)\2+$)        # \2 = smallest prime factor of tail
    (                     # Loop/iterate the following:
        (?=\2+$)              # Assert tail is still divisible by \2
        (?=(x+)(\4+$))        # \4 = largest proper divisor of tail
                                   = tail / \2 (implicitly);
                              # \5 = tail - \4 (a tool to make tail = \4)
        \5                    # tail -= \5, i.e. tail = \4
    ){2,}                 # Iterate the above at least 2 times
)*                    # Iterate the above any number of times, minimum 0
x$                    # Assert tail == 1

Retina 0.8.2, 56 bytes

.+
$*
^((?=(11+?)\2+$)((?=\2+$)(?=(1+)(\4+$))\5){2,})*1$

Try it online!

Vyxal g, 23 bitsv2, 2.875 bytes

∆Ǐċ

Try it Online!

Bitstring:

00010101110001100111100

Prime exponents, check if not equal to one, minimum of that list (will always be greater than one for a powerful number)

Perl 5 -ap, 43 bytes

//&map$\+=$_**2*$'**3=="@F",@;for@;=1..$_}{

Try it online!

Mathematica, 40 39 38 36 27 bytes

FactorInteger@#1∨#==1&

The first is \[VectorGreater], the second is \[Or\]. Assuming UTF-8 encoding, they both occupy 3 bytes.

Try this online!

APL(NARS), 8 chars

1∊≢¨⊂⍨π⎕

It return 0 if the number is as question ask, 1 otherwise. It is read in reverse ⎕π⍨⊂¨≢∊1 Call for input,π return the list of factors of input, ⍨⊂ doing partition as inputinput,¨≢ for each element list, of partition return the lenght,∊1 see if in the last list there is 1

test:

      1∊≢¨⊂⍨π⎕
⎕:
      36
0
~
      a/⍨∼{1∊≢¨⊂⍨π⍵}¨a←⍳100
┌14─────────────────────────────────────┐
│ 1 4 8 9 16 25 27 32 36 49 64 72 81 100│
└~──────────────────────────────────────┘

Nekomata + -e, 3 bytes

ƒ1>

Attempt This Online!

ƒ1>
ƒ       Factor
 1>     Check if all exponents are greater than 1

Python, 43 bytes

f=lambda n,c=1:f(n,c+1)if c**n%n else n/c%c

Try it online!

Outputs Truthy/Falsey reversed. A different method than dingledooper's solution, without using square roots.

The idea is to find the square-free part c of n, that is, the product of the distinct prime factors of n. We do this by counting up to the smallest c where c**n%n is 0, which checks that the prime factors of c, if copied many times, cover those of n.

Having found c, we check whether n/c%c is zero, which is equivalent to n being divisible by c**2. This confirms that n includes each of its prime factors at least twice. This also works in Python 2 where / is integer division rather than float division, since n is divisible by c, for a solution with only exact integer arithmetic.

Rather than finding the smallest c with c**n%n, we could instead check all values of c from 1 to n for one where c**n%n and n/c%c are both 0. This could look like:

44 bytes

f=lambda n,c=1:c>n or(c**n%n+n/c%c)*f(n,c+1)

Try it online!

39 bytes with exit code

def f(n,c=1):c**n%n+n/c%c>0!=f(n,-~c%n)

Try it online!

From @loopy walt

Python 2, 42 bytes

d=n=input()
while n%d**2:d-=1
print d**n%n

Try it online!

Finds the largest value d where n is divisible by d**2, then checks that it includes each distinct prime factor of n via d**n%n being zero.

C, 69 63 bytes

-6 bytes thanks to @c-- suggesting to reverse the loops and pointing out that I'd managed to leave in an unused variable.

i,j;f(n){for(i=n;i;i--)for(j=n;j;j--)n*=i*i*j*j*j!=n;return!n;}

Try it online!

Desmos, 47 bytes

f(k)=0^{∏_{n=1}^{k^{.5}}mod((k/n^2)^{1/3},1)}

In case it bothers anyone, k/n^2 can't be shortened to k/nn because k/nn is parsed as k/n * n when we actually want k/(n*n).

Try It On Desmos!

Try It On Desmos! - Prettified

Ruby -rprime, 32 bytes

Prime.prime_division returns a number's prime factors \$\prod_{k=1}^\infty {p_k}^{e_k}\$ in the form [ [p1, e1], [p2, e2], ... ] so this function checks whether every exponent is 2 or more.

->n{n.prime_division.all?{_2>1}}

Attempt This Online!

TI-BASIC (TI-84 Plus/Plus CE), 35 27 Bytes

-8 bytes thanks to Bbrk24

Prompt A:For(B,1,A:If not(fPart(√(A/B:Stop:End:Disp 0

The thing right after A/B is a cube (3). The thing right before the A/B is a sqrt symbol.

Does nothing and terminates if your number is powerful and prints 0 and terminates if your number is not powerful.

Ungolfed

Prompt A
For(B,1,A
If not(fPart(√(A/B
Stop
End
Disp 0

Explained

Prompt A              Asks user for input A
For(B,1,A             For loop: increase B by 1 from 1 until it reaches A
If                    If...
            √(        square root of...
              A/B    A/B^3...
  not(fPart(          is a whole number...
Stop                  then stop execution.
End                   End of while loop, go back to While A>B
Disp 0                If, eventually, B does exceed A, then A is not a powerful number.

TI-BASIC programs are scored by tokens bytes, not characters.
TI-BASIC also completes parentheses for you.

Edit: Test cases

Truthy:
123

Falsy:
456

Brachylog, 8 bytes

Ċ^₂ʰ^₃ᵗ×

Try it online!

Takes input as the Output variable. Outputs true. or false. as you would expect.

Explanation

It’s just a description of the alternative definition.

Ċ          Take a couple of 2 variables
 ^₂ʰ       Square the first one
    ^₃ᵗ    Cube the last one
       ×   Multiply them: it must be equal to the given input
           Brachylog will implicitly check if such a couple of variables Ċ exists

Dyalog APL, 21 bytes

⊢(⊣|*⍨)0⌈/∘⍸⍤=⊢|⍨2*⍨⍳

port of xnor's Python answer. Outputs inverse truthy value

⊢(⊣|*⍨)0⌈/∘⍸⍤=⊢|⍨2*⍨⍳ ⍝ implicit n
                    ⍳ ⍝ list values 1..n
                 2*⍨ ⍝ square each value
              ⊢|⍨    ⍝ mod by n
        0   =        ⍝ find where index is 0
         ⌈/∘⍸⍤        ⍝ Get max index divisible (d)
⊢(⊣|*⍨)              ⍝ then check d^n mod n

Thunno 2 G, 2 bytes

ḟḅ

Try it online! or verify the first few powerful numbers

Port of Unrelated String's Jelly answer. Output with inverted booleans. Add the ! flag to take the logical NOT.

Explanation

    # Implicit input
ḟ   # Get the list of prime factor exponents
 ḅ  # Check for each if it equals one
    # Take the maximum of this list
    # Implicit output

JavaScript, 32 bytes

A port of xnor's solution to JavaScript:

f=(n,c=1)=>c**n%n?f(n,c+1):n/c%c

Vyxal, 4 bytes

ǏΠ²Ḋ

Try it Online!

Uses Command Master's insight that these are numbers where the product of the distinct prime factors of the input is divisible by the input.

ǏΠ²Ḋ  # implicit input of integer
Ǐ     # distinct prime factors
 Π    # the product of this list
  ²   # squared
   Ḋ  # is divisible by the (implicit) input

Japt, 7 bytes

k e@vX²

Try it here

Racket, 101 bytes

(define(f n)((λ(D ?)(=(count(λ(p)(and(? p n)(?(sqr p)n)))D)(length D)))(prime-divisors n)divides?))

Try it online!


Explanation

We create a function f that takes one input n. We find the list of prime divisors of n and call it D. We then iterate through the list and check whether n is divisable by each element and n is divisable by each element squared. If both conditions are satisfied, we increment a counter. After iterating through list, we retrieve the total count and test whether the count is the same as the length of the list of divisors. If it is, then the number is a Powerful Number.

The ungolfed version is simpler to understand:

(define (f n)
  (let ([D (prime-divisors n)])
    (= (count (lambda (p)
                (and (divides? p n)
                     (divides? (sqr p) n)))
              D)
       (length D))))

Have a wonderful weekend ahead!

R, 24 bytes

\(n)all((n/1:n)^.5%%1:n)

Attempt This Online!

Port of @dingledooper's approach.


R, 26 bytes

\(n,i=1:n)n%in%(i^2%o%i^3)

Attempt This Online!

Uses the alternative characterization from the question.

Octave, 22 bytes

@(n)n-(t=1:n).^2'*t.^3

Try it online! The footer code contains truthiness/falsihood test.

Or verify all test cases. The footer code displays the input number if powerful (falsy output), or -- otherwise (truthy output).

Arturo,  33  30 bytes

$=>[in? 1tally factors.prime&]

Try it!

Port of Unrelated String's Jelly answer.

$=>[               ; a function where input is assigned to &
    in? 1          ; is 1 in
    tally          ; counts of
    factors.prime& ; input's prime factors
]                  ; end function

Charcoal, 25 bytes

Nθ⊙…·²θ∧∧¬﹪θι﹪θ×ιι⬤…²ι﹪ιλ

Try it online! Link is to verbose version of code. Outputs an inverted Charcoal boolean, i.e. - if the input is not a powerful number, nothing if it is. Explanation:

Nθ                          Input as an integer
   …·                       Inclusive range from
     ²                      Literal integer `2` to
      θ                     Input integer
  ⊙                         Any value satisfies
           θ                Input integer
         ¬﹪                 Is divisible by
            ι               Current value
        ∧                   Logical And
              θ             Input integer
             ﹪              Is not divisible by
               ×ιι          Current value squared
       ∧                    Logical And
                   …        Range from
                    ²       Literal integer `2` to
                     ι      Current value
                  ⬤         All satisfy
                       ι    Outer value
                      ﹪     Is not divisible by
                        λ   Inner value
                            Implicitly print

Retina 0.8.2, 64 bytes

.+
$*
^((.){2,})(?<!^\3+(..+))\1*$(?<!^\4*(?(2)$)(((?<-2>)\1)+))

Try it online! Link includes test cases. Outputs 0 for a powerful number, 1 if not. Explanation:

.+
$*

Convert to unary.

^((.){2,})

Search for a nontrival integer...

(?<!^\3+(..+))

... that is not composite...

\1*$

... and is a factor of the input...

(?<!^\4*(?(2)$)(((?<-2>)\1)+))

... and whose square is not a factor of the input.

K (ngn/k), 18 bytes

{|/~1!%x%/3#,1+!x}

Try it online!

Works more like dingledooper's Python solution.

{|/~1!%x%/3#,1+!x}
             1+!x   1..x
       x%/3#,       starting from x, divide by above three times
      %             square root of each
 |/~1!              test if any of them has zero fractional part

K (ngn/k), 22 bytes

{|//x=*/:/1_*\3#,1+!x}

Try it online!

A bit of a convoluted way to check if the given number x is a^2 * b^3. Returns 1 if x is a powerful number, 0 otherwise.

{|//x=*/:/1_*\3#,1+!x}
                 1+!x   1..x inclusive -> A
              3#,       an array that contains three copies of A
            *\     cumulative product (A; A^2; A^3)
          1_       drop first
      */:/    reduce by cartesian product by multiplication
    x=        boolean matrix indicating each number is equal to input
 |//          max of all booleans

Factor + math.primes.factors math.unicode, 30 29 bytes

[ group-factors unzip 1 ∋ ]

Try it online!

Port of Unrelated String's Jelly answer.

-1 by using unzip instead of values to get at the exponents

05AB1E, 3 bytes

Ó1å

Outputs an inverted 05AB1E boolean: \$1\$ if it's NOT a powerful numbers; \$0\$ if it is a powerful number (only 1 is truthy in 05AB1E).

Port of @UnrelatedString's Jelly answer, so make sure to upvote that answer as well!

Try it online or verify all test cases.

Explanation:

Ó    # Get a list of exponents of the (implicit) input's prime factorization
 1å  # Does this list contain a 1?
     # (after which the result is output implicitly)

Python 3, 43 bytes

Returns False for a powerful number, and True otherwise.

f=lambda n,i=1:i>n or(n/i)**.5%i>0<f(n,i+1)

Try it online!

Checks the condition that n is in the form a^2*b^3 by asserting that n/a^3 is a perfect square. In Python this would look something like (n/a**3)**.5%1==0. This condition can be rearranged so that it is slightly golfier:

(n/a**3)**.5%1==0
n**.5/a**1.5%1==0
n**.5/a**.5/a%1==0
(n/a)**.5/a%1==0
(n/a)**.5%a==0

J, 12 10 8 bytes

1 e._&q:

Try it online!

-2 by using Unrelated String's approach of checking for 1 instead of verifying that every exponents was 2 or more

-2 thanks to Bubbler for a shorter way to get prime exponents

Excel, 42 bytes

=LET(a,SEQUENCE(A1),OR(a^2*TOROW(a^3)=A1))

Input in cell A1.

Jelly, 4 bytes

ÆE1e

Try it online!

Inverted native truthy/falsy semantics: 0 for powerful numbers, 1 otherwise.

  1e    Is 1 an element of
ÆE      the array of the input's prime exponents?