"""
File: largest_digit.py
Name: 陳名娟 <NAME>
----------------------------------
This file recursively prints the biggest digit in
5 different integers, 12345, 281, 6, -111, -9453
If your implementation is correct, you should see
5, 8, 6, 1, 9 on Console.
"""


def main():
	print(find_largest_digit(12345))      # 5
	print(find_largest_digit(281))        # 8
	print(find_largest_digit(6))          # 6
	print(find_largest_digit(-111))       # 1
	print(find_largest_digit(-9453))      # 9


def find_largest_digit(n):
	"""
	:param n: int, the original integer
	:return: int, the biggest digit
	"""
	if 0 < n < 10 or 0 < -n < 10:
		return n
	else:
		if n < 0:
			n = -n
		return find_largest_digit_helper(n, 0)


def find_largest_digit_helper(n, compare):
	"""
	:param n: int, the original integer
	:param compare: int, the candidate of the biggest digit
	:return: int, return the biggest digit
	"""
	if n == 0:
		return compare
	else:
		if n % 10 > compare:
			compare = n % 10
		n = n // 10
		return find_largest_digit_helper(n, compare)


if __name__ == '__main__':
	main()

"""
File: largest_digit.py
Name: 陳名娟 <NAME>
----------------------------------
This file recursively prints the biggest digit in
5 different integers, 12345, 281, 6, -111, -9453
If your implementation is correct, you should see
5, 8, 6, 1, 9 on Console.
"""


def main():
	print(find_largest_digit(12345))      # 5
	print(find_largest_digit(281))        # 8
	print(find_largest_digit(6))          # 6
	print(find_largest_digit(-111))       # 1
	print(find_largest_digit(-9453))      # 9


def find_largest_digit(n):
	"""
	:param n: int, the original integer
	:return: int, the biggest digit
	"""
	if 0 < n < 10 or 0 < -n < 10:
		return n
	else:
		if n < 0:
			n = -n
		return find_largest_digit_helper(n, 0)


def find_largest_digit_helper(n, compare):
	"""
	:param n: int, the original integer
	:param compare: int, the candidate of the biggest digit
	:return: int, return the biggest digit
	"""
	if n == 0:
		return compare
	else:
		if n % 10 > compare:
			compare = n % 10
		n = n // 10
		return find_largest_digit_helper(n, compare)


if __name__ == '__main__':
	main()

File: largest_digit.py Name: 陳名娟 <NAME> ---------------------------------- This file recursively prints the biggest digit in 5 different integers, 12345, 281, 6, -111, -9453 If your implementation is correct, you should see 5, 8, 6, 1, 9 on Console. # 5 # 8 # 6 # 1 # 9 :param n: int, the original integer 	:return: int, the biggest digit :param n: int, the original integer 	:param compare: int, the candidate of the biggest digit 	:return: int, return the biggest digit