Skip to main content
1 of 4
Digital Trauma
  • 73k
  • 9
  • 112
  • 264

#dc, 7

?dvd*-p

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

Try it online.

?          # Push input.  Stack: [ n ]
 dv        # duplicate and take integer square root.  Stack: [ ⌊√n⌋, n ]
   d       # duplicate.  Stack: [ ⌊√n⌋, ⌊√n⌋, n ]
    *      # multiply.  Stack: [ ⌊√n⌋², n ]
     -     # take difference. Stack: [ n-⌊√n⌋² ]
      p    # print.
Digital Trauma
  • 73k
  • 9
  • 112
  • 264