euler algorithm solve