Created
July 28, 2014 07:29
-
-
Save sakamotodesu/8b54182f27001ea55adb to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import scala.math.BigDecimal | |
import scala.util.Random | |
object Main { | |
def main(args: Array[String]) { | |
Random.shuffle(List.range(1, args(0).toInt)).par.foreach(x=>println(x + " : " + pow4div3(x))) | |
} | |
def pow4div3(n: Int) = { | |
def rec(m: BigDecimal):Boolean ={ | |
//println(" " + m) | |
if(m < 0.5) | |
true | |
else if ((m % 1) >= 0.5) | |
false | |
else | |
rec(m/3) | |
} | |
rec(BigDecimal(4).pow(n)) | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment