Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- object GreatestDivisor {
- def main(args: Array[String]){
- var list2 = args
- for (j <- 0 to list2.length-1) {
- if (scala.util.Try(list2(j).toInt).isFailure){
- println(list2(j) + " : the conversion is not possible")
- }
- else if (scala.util.Try(list2(j).toInt).isSuccess){
- print(list2(j).toInt + " : ")
- GetDivisor(list2(j).toInt)
- }
- }
- }
- def GetDivisor(y: Int): Unit = {
- for (i <- 1 to y){
- if (y.toFloat/(y.toFloat-i) == math.floor(y.toFloat/(y.toFloat-i))) {
- return (println(y-i))
- }
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement