josephusProblem( Get link Facebook X Pinterest Email Other Apps June 24, 2019 def josephusProblem(n, k): i = 0 c = list(range(1, n + 1)) while len(c) != 1: i += (k - 1) i %= len(c) del c[i] return c[0] Read more
complex number code Get link Facebook X Pinterest Email Other Apps June 22, 2019 func arrayComplexElementsProduct(real: [Int], imag: [Int]) -> [Int] { var x = real[0] var y = imag[0] for i in 1..<real.count { let a = x*real[i] - y*imag[i] let b = x*imag[i] + y*real[i] x = a y = b } return [x,y] } Read more