Help please (I dont get it) | SoloLearn: Learn to code for FREE!

0

Help please (I dont get it)

https://edabit.com/challenge/2QvnWexKoLfcJkSsc public class Program13 { public static int[] ArrayOfMultiples(int num, int length) { int[] hello; for (int i = 1; i <= length; i++) { hello = Convert.ToInt32(Math.Pow(num, i)); } return hello; } } visual studios says: int cant be converted to int[]

6/1/2020 2:25:07 PM

Michael

2 Answers

New Answer

+1

I'm not sure but see if this works. public class Program { public static int[] ArrayOfMultiples(int num, int length) { int[] hello = new int[length]; int x = 1; for (int i = 0; i < length; i++) { hello[i] = Convert.ToInt32(Math.Pow(num, x)); x++; } return hello; } }

0

Michael int cannot be equal to array. You can do like Avinesh did Or use list instead: public static int[] abc(int x, int y){ List<int> xyz = new List<int>(); for(int i=0;i<y;i++) xyz.Add((int)Math.Pow(x,i)); return xyz.ToArray(); }