/* * Reference: http://lizan.asia/blog/2012/12/11/scala-competitive/ */ object Main extends App { import java.{util => ju} import scala.annotation._ import scala.collection._ import scala.collection.{mutable => mu} import scala.collection.JavaConverters._ import scala.math._ val sc = new ju.Scanner(System.in) @tailrec def calc(t:Long, n : Long) : Long={ () match { case _ if n % t == 0 => t case _ if 2 * n < t * t => if (n % 2 == 0) n / 2 else n case _ => calc(t + 1, n) } } val n = sc.nextLong println(calc(3, n)) }