Euler Algorithm with input