Using Power(Math)

How can I make a console app that shows numbers which is xyz=x^x+y^y+z^z ?
You can use the function pow (which is the header math.h). It's written like this -> pow(base,exponent) and it returns the value of the power.

otherwise you can make a cicle with the base * itself exponent times.
1
2
3
4
5
6
7
8
9
10
#include <iostream>
#include <tgmath.h>
int main()
{
    for (int x=-10;x<10;x++)
        for (int y=-10;y<10;y++)
            for (int z=-10;z<10;z++)
                if ((x*y*z) == (pow(x, x) + pow(y, y) + pow(z, z)))
                    std::cout << x << " " << y << " " << z << std::endl;
}
Topic archived. No new replies allowed.