Skip to main content
3 of 4
added 28 characters in body
Michael M.
  • 12.1k
  • 4
  • 25
  • 41

JavaScript (ES6) 29

Supports negative power.

f=n=>(n&2?'-':'')+(n&1?'i':1)

ES5 :

function f(n){return (n&2?'-':'')+(n&1?'i':1)}
Michael M.
  • 12.1k
  • 4
  • 25
  • 41