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![](https://ecs-static.teamtreehouse.com/assets/views/marketing/shared/community-banner-white-47072046c51352fe6a69f5e691ff5700b28bb11d45197d7bdf066d9ea3f72d0c.webp)
![Calvin Secrest](https://uploads.teamtreehouse.com/production/profile-photos/4043962/micro_meta2.jpg)
Calvin Secrest
24,815 PointsGetting Past the C# List<T> for list of integers Challange
The code below works fine in the IDE, but will not let me pass the challenge.
Directions: "Create a static method named GetPowersOf2 that returns a list of powers of 2 from 0 to the value passed in. So if 4 was passed in, the function would return { 1, 2, 4, 8, 16 }. The System.Math.Pow method will come in handy."
Error: " Bummer! Does MathHelpers.GetPowersOf2 return List`1?"
Does anyone now what the Code Challenge is looking for (besides what its asking)
Thanks
using System.Collections.Generic;
using System;
namespace Treehouse.CodeChallenges
{
public static class MathHelpers
{
public static List<int> GetPowersOf2(int input)
{
var returnList = new List<double>();
for (int 1 = 0; i <= input; i++)
{
returnList.Add((int)Math.Pow(2, i));
}
}
}
}
2 Answers
![Eduardo Parra San Jose](https://secure.gravatar.com/avatar/2fb0008e5672403d68315f192442f286?s=96&d=https%3A%2F%2Fecs-static.teamtreehouse.com%2Fassets%2Fcontent%2Fdefault_avatar-445fbbabfc8dc9188fb5967fe43322ee0c3e0dd1e10f378bf8343784af5a13eb.webp&r=pg)
Eduardo Parra San Jose
12,579 PointsHi,
I hope the following tips helps out to solve the challenge:
- The GetPowersOf2 method performs actions but it doesn't include a return statement to return the List
- Variable names cannot start with a number, so in the for loop the variable cannot be called 1, I guess what you wanted was to call it i
- In the signature of the method it says a list of int will be returned, but the returnList type is a list of double
Many thanks. Have a nice day, edu
![Eduardo Parra San Jose](https://secure.gravatar.com/avatar/2fb0008e5672403d68315f192442f286?s=96&d=https%3A%2F%2Fecs-static.teamtreehouse.com%2Fassets%2Fcontent%2Fdefault_avatar-445fbbabfc8dc9188fb5967fe43322ee0c3e0dd1e10f378bf8343784af5a13eb.webp&r=pg)
Eduardo Parra San Jose
12,579 PointsYou're welcome :)
Calvin Secrest
24,815 PointsCalvin Secrest
24,815 PointsThank you for this assistance!