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

C# C# Collections Lists Lists

how

how the hell do I do this code

Create a static method named GetPowersOf2 that returns a list of integers of type List<int> containing the powers of 2 from 0 to the value passed in. For example, if 4 is passed in, the method should return this list of integers: { 1, 2, 4, 8, 16 }. The System.Math.Pow method will come in handy.

1 Answer

Reggie Williams
STAFF
Reggie Williams
Treehouse Teacher

Hey Jamie Corbett since you have to do something a given amount of times it might be a good place for a for loop. Your method should take a value that represents where the loop should start and inside the loop you can square and return the passed in value