Skip to content

Instantly share code, notes, and snippets.

@sakamotodesu
Created July 28, 2014 07:29
Show Gist options
  • Save sakamotodesu/8b54182f27001ea55adb to your computer and use it in GitHub Desktop.
Save sakamotodesu/8b54182f27001ea55adb to your computer and use it in GitHub Desktop.
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