java program help!! ok so i have to "write a for loop indexed by the int variable k to print out the sum of the function k^k for k starting at 1 and ending with N, where N is an integer command-line, input. In other words the sum; " sum = 1^1 + 2^2 + 3^3 + 4^4 +5^5 +.....+(N-1)^(N-1) + N^N i hope this makes sense.....but i just need to output the sum for the given input... i was trying to do it but it doesn't work
public static void main (String args[]) { double Pow,Sum; System.out.println("Enter a number"); int UserIn =in.readln; for(int i=1;i<=UserIn ; i++) Pow=i*i; Sum=+Pow System.out.print("Sum= " + Sum + "+" ); } sorry I didnt test it but I think it will do the job
hey thanks I actually just got the program to work after I posted the question, but thank anyways! :).
you welcome @mxn5051
Join our real-time social learning platform and learn together with your friends!