How to do exponentiation in clojure?

前端 未结 13 2016
执笔经年
执笔经年 2021-01-30 12:32

How can I do exponentiation in clojure? For now I\'m only needing integer exponentiation, but the question goes for fractions too.

13条回答
  •  庸人自扰
    2021-01-30 12:37

    You can use java's Math.pow or BigInteger.pow methods:

    (Math/pow base exponent)
    
    (.pow (bigint base) exponent)
    

提交回复
热议问题