greatest common divisor solved recursively and iteratively based on prog()