Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- # Two simple tasks drill - https://programmingpraxis.com/2021/01/05/two-simple-tasks
- function task1(n::Int64) # I could probably do this in Rust too!
- x = 1;
- m = 5;
- while x <= n
- print(x, " ")
- x *= m;
- m = ifelse(m == 5, 2, 5);
- end
- end
- function task2(n::Int64 = 2673) # it's highly unlikely we'll find anything beyond 2673.
- for x = 1:n
- x11 = x / 11;
- x11r = round(x11);
- if x11 == x11r
- digits = map(x -> parse(Int64, x), split(string(x), ""));
- s = digits[1]^2;
- if length(digits) == 2
- s += digits[2]^2;
- else
- s += digits[2]^2 + digits[3]^2;
- end
- if s == x11; print(x, " "); end
- end
- end
- end
Add Comment
Please, Sign In to add comment