Skip to main content
2 of 4
added 147 characters in body
Digital Trauma
  • 73k
  • 9
  • 112
  • 264

#dc, 9

0?dvd*-^p

Outputs 0 for truthy and an integer > 0 for falsey.

Try it online.

0            # Push zero.  Stack: [ 0 ]
 ?           # Push input.  Stack: [ n, 0 ]
  dv         # duplicate and take integer square root.  Stack: [ ⌊√n⌋, n, 0 ]
    d        # duplicate.  Stack: [ ⌊√n⌋, ⌊√n⌋, n, 0 ]
     *       # multiply.  Stack: [ ⌊√n⌋², n, 0 ]
      -      # take difference. Stack: [ n-⌊√n⌋², 0 ]
       ^     # 0 to power of the result.  Stack: [ 0^(n-⌊√n⌋²) ]
        p    # print.

Note dc's ^ exponentiation command gives 00=1 and 0n=0, where n>0.

Digital Trauma
  • 73k
  • 9
  • 112
  • 264