Advertisement
Guest User

Untitled

a guest
Mar 18th, 2019
102
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Scala 0.58 KB | None | 0 0
  1. object GreatestDivisor {
  2.   def main(args: Array[String]){
  3.     var list2 = args
  4.  
  5.     for (j <- 0 to list2.length-1) {
  6.       if (scala.util.Try(list2(j).toInt).isFailure){
  7.         println(list2(j) + " : the conversion is not possible")
  8.       }
  9.       else if (scala.util.Try(list2(j).toInt).isSuccess){
  10.         print(list2(j).toInt + " : ")
  11.         GetDivisor(list2(j).toInt)
  12.       }
  13.     }
  14.   }
  15.  
  16.   def GetDivisor(y: Int): Unit = {
  17.     for (i <- 1 to y){
  18.       if (y.toFloat/(y.toFloat-i) == math.floor(y.toFloat/(y.toFloat-i))) {
  19.         return (println(y-i))
  20.       }
  21.     }
  22.   }
  23. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement