• #### Jay Learn

It would have been easy if you would have mentioned whether the given problem is to be solved using 'for' or 'while' loop!

• #### Jay Learn

I can't solve this problem. The cheat button isn't visible too. Help Me.

• #### Learneroo

It can be solved with either kind of loop. This question may be too hard, so I will add some more explanation (and a cheat option).

• #### Learneroo

Update: I created a new easier challenge for the While and For Loops Node. I changed this node to Loopy Thinking, and added some more help.

• #### James Montgomery

This is what I did, I don't understand the setting of variable to 1, I set mine to 2 and it worked.
public static int doStuff(int a, int b){
int product=a;
for(int i=2;i<=b;i=i+1){product=product*a;}
return product;
}

• #### James Montgomery

I changed it, and it still works, but i think this is more correct and will have less errors with certain numbers. public static int doStuff(int a, int b){
int product=1;
for(int i=1;i<=b;i=i+1){product=product*a;}
return product;

• #### Learneroo

James, I changed the explanation to just show the code. My mention of setting the variable to 1 would have been relevant if I had cases where the exponent was 0, but I decided to leave them out. This means your first solution would also work.

• #### moses

(complete noob running through ) I cant figure this out :(. Can someone please explain what is happening with the Zonko problem...

• #### Learneroo

@moses, there are now 3 challenges which all follow the same idea...

• #### Tyler Pond

Anyone having problems, try thinking about it as that a needs to be multiplied by a, b amount of times.

• #### Victoria Holland

This was a tough one. I originally put the following code, which was incorrect:
int solution = 0;
for (int i=0; i<=b; i++)
{
solution += (a * a);
}
return solution;

• #### Jamison Norwood

The best thing to do is to take physical notes of the previous lesson and come back to here. My notes really helped.

• #### David

Thanks much from learneroo for helping noobs like myself to learn a bit more. My 25 cents for this exercise even though i may be going to ahead of time is that it would have been useful to know

• #### Oliver Cross

This is the easiest way

<<int Solution = (int) Math.pow(a, b);
return Solution;

• #### Colt Wolff

``````int solution = 1;
for(int i=1; i <= b; i =i+1){
solution = a * solution;
}
return solution;
``````
• #### Bernard Mitchell

I'm stuck on the first one. The loop stops when the condition is no longer true. If I do a+b>i; . Sum=sum+1 aka a=a+1; will run until the condition is no longer true. However I keep getting incorrect. Appreciate the advice thanks.

• #### Bernard Mitchell

@learneroo can I get some help in reference to my comment. Thank you.

• #### Learneroo

`a+b>i` does not work as the condition since it doesn't look at `i`. Try it out with an example, e.g. where a is 3 and b is 5. Also, the goal is to not add numbers greater than 1 together. How many times should you add 1 to `a` to reach a+b?