+ 2

Why log2 gives unresolved reference in Sololearn?

Sololearn gives unresolved reference when I am importing kotlin.math library and when using the function log2(). In IntelliJ it works fine. Is this a problem in Sololearn? https://code.sololearn.com/cfzQUhnK1jo7/?ref=app

19th Jun 2020, 1:19 PM
Ayan
2 Answers
+ 4
log2 was added in version 1.2. SoloLearn is still using 1.1. This should calculate it for you: fun log2(n: Double) = Math.log(n)/Math.log(2.0)
19th Jun 2020, 11:12 PM
John Wells
John Wells - avatar
+ 3
I had to use that formula only. Thanks sir.
20th Jun 2020, 4:18 AM
Ayan