Mọi người viết phương trình pascal giúp em ạ. E cảm ơn nhiều lắm
Cho 1 số N, in ra số cuối của phép lũy thừa 1378 mũ N
VD: N=1 thì 1378^1 =1378. Vậy chữ số cuối là 8
VD2: N=2 thì 1378^2=1898884. Vậy chữ số cuối là 4
P/s: Mọi người giúp em ạ. Nếu được em hứa sẽ vote 5 sao và cám ơn ạ
uses crt;
var n:longint;
begin
clrscr;
write(‘n=’);readln(n);
write(‘Chu so cuoi cung cua 1378 ^ ‘,n,’ =’);
if n mod 4=1 then writeln(‘8’);
if n mod 2=0 then writeln(‘4’);
if n mod 3=0 then writeln(‘2’);
if n mod 4=0 then writeln(‘6’);
readln
end.
///////////
Bài này mình làm theo quy tắ chữ số cuối của một lũy thừa có tận cùng cơ số là 8!
Text
program oken;
uses crt;
var n : integer;
begin
clrscr;
write(‘Nhap n: ‘); readln(n);
write(‘Chu so cuoi cung cua 1378^’,n,’: ‘);
if (n mod 3=0) then
write(‘2’)
else if (n mod 2=0) then
write(‘4’)
else if (n mod 4=0) then
write(‘6’)
else
writeln(‘8’);
readln;
end.