Welcome to the Treehouse Community
Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.
Looking to learn something new?
Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.
Start your free trial
warda sy
74 Pointscan enyone help me with this in python
i have to find the two smallest numbers between 3 for example this : Two_Smallest(1,3,2) and in need to return sum of (2+1) i need help to get the algoritim in python without recursion
1 Answer
Steven Parker
243,318 PointsThis seems really simple, are you sure it doesn't involve lists?
But if there is always 3 arguments recursion would be over-complicating it. All you'd need is to compare the arguments with each other to determine which is larger, and then return the sum of the other two.
Just a few "if" statements and "return"s should do it.
I'd be afraid I was doing your homework if I was any more explicit!
warda sy
74 Pointswarda sy
74 Pointsthank you, i thought the hard way to find the two smallest, never thought to find the largest which leaves me with the smallest! thank for the idea and im just new in python and in all programing