I am trying to summation,where the baseNumber is from 1-4 and the expNumber is,i tried to use the for loop but isnt work and dont know where the problem is.Where the i shoudl get raised until 4 and so the basnum.
I tried to change places of number but what the weirdest thing is the sum get sometimes negative.
public static void main(String[] args) {
int basenum = 1;
int exp = 2;
metoda(basenum,exp);
}
public static void metoda(int basenum,int exp)
{
for(int i = 1; i <= 4; i++)
{
int sum = basenum * basenum;
basenum++;
System.out.println(sum);
}
}
(Edited) now i get 1,4,9,25(those answer that i wanted) but now i want instead of all number i want to output the 1+4+9+25=30(the 30 as output).