Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- # R solution to codeabbey challenge 24
- seed = c(3488, 373, 5368, 751, 8342, 3416, 843, 6173, 7019, 381, 1054, 6303)
- counter = 1
- rsp = list()
- vals = list()
- for (i in seed) {
- aux = i
- repeat {
- aux2 = trunc((aux * aux / 100) %% 10000)
- if (aux2 %in% vals) {
- rsp[length(rsp)+1] = counter
- break
- }
- vals [length(vals)+1] = aux
- counter = counter + 1
- aux = aux2
- }
- counter = 1
- vals = list()
- }
- cat(unlist(rsp))
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement