Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- // kotlin solution to codeabbey challenge 24
- fun main(args: Array<String>) {
- var inp2: IntArray = intArrayOf(3488, 373, 5368, 751, 8342, 3416, 843, 6173, 7019, 381, 1054, 6303);
- var counter = 0;
- var rsp = mutableListOf<String>();
- var vals = mutableListOf<Int>();
- var aux = 0;
- var aux2 = 0;
- for (i in inp2) {
- aux = i;
- label@ while (true) {
- aux2 = (aux * aux / 100) % 10000;
- if (vals.contains(aux)) {
- rsp.add(counter.toString());
- break@label;
- }
- vals.add(aux);
- counter += 1;
- aux = aux2;
- }
- counter = 0;
- vals.clear();
- }
- println(rsp.joinToString(" "));
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement