int power(int x, int y) {
        int i,power=1;
        if(y == 0)
        return 1;
        for(i=1;i<=y;i++)
        power=power*x;
        return power;
      }

      Java language logo
      Power of a number

      Java Recipes

      The code above calculates the power of a number x by multiplying it by itself the number of times equal to y-1.

      0 Comments

        Add Comment

        Log in to add a comment

        Codiga - All rights reserved 2022.