diff --git a/.idea/vcs.xml b/.idea/vcs.xml new file mode 100644 index 0000000..94a25f7 --- /dev/null +++ b/.idea/vcs.xml @@ -0,0 +1,6 @@ + + + + + + \ No newline at end of file diff --git a/src/main/kotlin/Main.kt b/src/main/kotlin/Main.kt index f2a59b6..ae3c23c 100644 --- a/src/main/kotlin/Main.kt +++ b/src/main/kotlin/Main.kt @@ -1,7 +1,39 @@ -fun main(args: Array) { - println("Hello World!") - // Try adding program arguments via Run/Debug configuration. - // Learn more about running applications: https://www.jetbrains.com/help/idea/running-applications.html. - println("Program arguments: ${args.joinToString()}") +fun main() { + var x: Int? = null; + var y: Int? = null; + var min: Int? = null; + var max: Int? = null; + + try { + print("X = "); + x = readLine()?.toInt() + + print("Y = "); + y = readLine()?.toInt() + + print("Min = "); + min = readLine()?.toInt() + + print("Max = "); + max = readLine()?.toInt() + } catch (_: NumberFormatException) {} + + + if(x != null && y != null && max != null && min != null && min <= max) { + val strings = List(max - min) { // Creo la lista utilizzando lambda expression + val n = it+min // it rappresenta l'indice della lista che sto inizializzando, il numero corrispondente รจ quindi it+min + if(n % x == 0) { + "Cip" + } else if(n % y == 0) { + "Ciop" + } else { + n + } + } + + println(strings) + } else { + println("Input non valido") + } } \ No newline at end of file