mình ghi phần chính thôi nhé!
writeln('nhap n');readln(n);
1.For i:=1 to 9 do writeln(n,'x',i,'=',n*i);
2.for i:=1 to n do if (n mod i =0) and ( i mod 2 = 0) then writeln(i);
3.for i:=1 to n do if (n mod i =0) and ( i mod 2 = 1) then writeln(i);
4. uocchung:=1;for i:=1 to n do if n mod i = 0 then uocchung:=uocchung+i;
5. For i:=2 to n-1 do if n mod i = 0 then begin
if n = i then writeln( n,' la so nguyen to') else writeln(n, 'khong phai la so nguyen to');
Câu 1:
uses crt;
var i,n:integer;
begin
clrscr;
write('Nhap n='); readln(n);
writeln('Bang cuu chuong ',n,' la: ');
for i:=1 to 10 do
writeln(n,'*',i,'=',n*i);
readln;
end.
Câu 2:
uses crt;
var i,n:integer;
begin
clrscr;
write('Nhap n='); readln(n);
for i:=1 to n do
if (n mod i=0) and (i mod 2=0) then write(i:4):
readln;
end.
Câu 3:
uses crt;
var i,n:integer;
begin
clrscr;
write('Nhap n='); readln(n);
for i:=1 to n do
if (n mod i=0) and (i mod 2=1) then write(i:4);
readln;
end.
Câu 4:
uses crt;
var i,n,t:integer;
begin
clrscr;
write('Nhap n='); readln(n);
t:=0;
for i:=1 to n do
if n mod i=0 then t:=t+i;
writeln(t);
readln;
end.
Câu 5:
uses crt;
var i,n,kt:integer;
begin
clrscr;
write('Nhap n='); readln(n);
kt:=0;
for i:=2 to n-1 do
if n mod i=0 then
begin
kt:=1;
break;
end;
if (kt=0) and (n>1) then writeln(n,' la so nguyen to')
else writeln(n,' khong la so nguyen to');
readln;
end.
Câu 6:
uses crt;
var i,a,b,ucln,x,y:integer;
begin
clrscr;
write('Nhap a='); readln(a);
repeat
write('Nhap b='); readln(b);
until b<>0;
if a<b then
begin
ucln:=1;
for i:=1 to a do
if (a mod i=0) and (b mod i=0) then
begin
if ucln<i then ucln:=i;
end;
end
else begin
ucln:=1;
for i:=1 to b do
if (a mod i=0) and (b mod i=0) then
begin
if ucln<i then ucln:=i;
end;
end;
x:=a div ucln;
y:=b div ucln;
writeln(a,'/',b,'=',x,'/',y);
readln;
end.
Câu 7:
uses crt;
var i,a,b,ucln:integer;
begin
clrscr;
write('Nhap a='); readln(a);
repeat
write('Nhap b='); readln(b);
until b<>0;
if a<b then
begin
ucln:=1;
for i:=1 to a do
if (a mod i=0) and (b mod i=0) then
begin
if ucln<i then ucln:=i;
end;
end
else begin
ucln:=1;
for i:=1 to b do
if (a mod i=0) and (b mod i=0) then
begin
if ucln<i then ucln:=i;
end;
end;
writeln(ucln);
readln;
end.
Câu 9:
uses crt;
var t,i,n:integer;
begin
clrscr;
write('Nhap n='); readln(n);
t:=0;
for i:=1 to n do
if i mod 2=0 then t:=t+i;
writeln(t);
readln;
end.
Câu 11:
uses crt;
var t,i,n:integer;
begin
clrscr;
write('Nhap n='); readln(n);
t:=0;
for i:=1 to n do
if i mod 2=1 then t:=t+i;
writeln(t);
readln;
end.
Câu 8:
uses crt;
var n,m,i,t:integer;
begin
clrscr;
write('Nhap n='); readln(n);
write('Nhap m='); readln(m);
t:=0;
for i:=n to m do
if i mod 2=0 then t:=t+i;
writeln(t);
readln;
end.
Câu 10:
uses crt;
var n,m,i,t:integer;
begin
clrscr;
write('Nhap n='); readln(n);
write('Nhap m='); readln(m);
t:=0;
for i:=n to m do
if i mod 2=1 then t:=t+i;
writeln(t);
readln;
end.
Câu 12:
uses crt;
var n,m,i,t:integer;
begin
clrscr;
write('Nhap n='); readln(n);
write('Nhap m='); readln(m);
t:=0;
for i:=n to m do
t:=t+i;
writeln(t);
readln;
end.
Câu 13:
uses crt;
var t,i,n:integer;
begin
clrscr;
write('Nhap n='); readln(n);
t:=0;
for i:=1 to n do
t:=t+i;
writeln(t);
readln;
end.
Câu 14:
uses crt;
var i,n:integer;
begin
clrscr;
write('Nhap n='); readln(n);
for i:=1 to n do
if n mod i=0 then write(i:4);
readln;
end.