👤

Se citeste un număr n.
SA SE AFISEZE ULTIMA CIFRA A LUI 2 LA PUTEREA n!


Răspuns :

#include <iostream>

using namespace std;

int main()

{

int n, uc;

cout << "Introduceti n :";

cin >> n;

if (n % 4 == 0)

 uc = 6;

if (n % 4 == 1)

 uc = 2;

if (n % 4 == 2)

 uc = 4;

if (n % 4 == 3)

 uc = 8;

if (n == 0)

 uc = 1;

cout << "\nU(2^" << n << ") = " << uc;

 

}


Ovdumi

#include <iostream>

using namespace std;

int main()

{

int n, uc;

cout << "Introduceti n :";

cin >> n;

if (n == 0)

{

 uc = 1;

 cout << "orice numar la puterea zero este 1 deci uc=" << uc<<endl;

 return 0;

}

else

if (n % 4 == 0)

 uc = 6;

if (n % 4 == 1)

 uc = 2;

if (n % 4 == 2)

 uc = 4;

if (n % 4 == 3)

 uc = 8;

cout << "\nU(2^" << n << ") = " << uc<<endl;

return 0;

}