yeap got it solved...
public int sumPowTo (int n, int k)
// Method for calculating sum of powers, which using the power method above
{
if ( n == 0) // Base case, if n equals to 0 the...
Type: Posts; User: Red
yeap got it solved...
public int sumPowTo (int n, int k)
// Method for calculating sum of powers, which using the power method above
{
if ( n == 0) // Base case, if n equals to 0 the...
from the tracing that i have made is 1^2+2^2+3^2+4^2 = 30 [int (4,2)}
or in other example 1^3+2^3+3^3+4^3+5^3 = 225 [int (5,3)]
that i need help in detecting the hole in my program and the reason...
i did try using n-1 and k-1 but the outcome still the same. i trace my program on the paper before i wrote the program the outcome is 30..
i got a little bit of problem with my coding for finding the total sum..
the formula given to me is 1^k+2^k+...+n^k.
my coding as follows:
public int sumPowTo (int n, int k)
{
...