I was trying to work this through recursion, I'm not exactly sure if I got it right. but I think I'm on the right track, since it seems that the greatest sum usually consists of a 3 and/or 2's.
def great_mult(num):
lists = []
if num <= 3:
lists.append(num)
return lists
if num % 3 == 0:
num = (num - 3)
lists.append(3)
lists.extend(great_mult(num))
else:
num = (num - 2)
lists.append(2)
lists.extend(great_mult(num))
return lists
It's nice to finally have some time to try the problems shown in class.
Wow it returns a list of the numbers! It seems right. I made a program to calculate the products and they match! :)
ReplyDeleteYa I wasn't sure if it would work for everything, since I only did a few examples and saw a vague pattern :P
ReplyDelete