Hãy nhập câu hỏi của bạn vào đây, nếu là tài khoản VIP, bạn sẽ được ưu tiên trả lời.
uses crt;
var i,n,m,j,kt:integer;
begin
clrscr;
readln(n,m);
for i:=n to m do
begin
kt:=0;
if (i>2) then begin
for j:=2 to trunc(sqrt(i)) do
if i mod j=0 then kt:=1;
if kt=0 then write(i:4);
end;
readln;
end.
program TinhTongGiaiThua;
uses crt;
var
n, num, sum, digitCount: integer;
function GiaiThua(x: integer): integer;
var
i, fact: integer;
begin
fact := 1;
for i := 1 to x do
begin
fact := fact * i;
end;
GiaiThua := fact;
end;
begin
clrscr;
write('Nhap so n: ');
readln(n);
sum := 0;
digitCount := 0;
while n > 0 do
begin
num := n mod 10;
sum := sum + GiaiThua(num);
digitCount := digitCount + 1;
n := n div 10;
end;
writeln('Tong giai thua cac chu so cua n la: ', sum);
writeln('Tong so chu so cua n la: ', digitCount);
readln;
end.
#include <bits/stdc++.h>
using namespace std;
long long n,t,x,a;
int main()
{
cin>>n;
a=n;
t=0;
while (n>0)
{
x=n%10;
t=t+x*x*x;
n=n/10;
}
if (n==t) cout<<"Yes";
else cout<<"No";
return 0;
}
program ct;
uses crt;
var dem,n,s,max,t:longint;
begin
writeln('nhap n:');readln(n);
while n>0 do begin
s:=n mod 10;
t:=t+s;
if max<s then max:=s;
dem:=dem+1;
n:=n div 10;
end;
writeln('tong la',t,',','co',' ',dem,' ','chu so',',','chu so lon nhat la:',max);
readln
end.
bạn xem lại nha mik làm đây nhưng k bt đk
bt2:
Program Tinh_Tong;
var N,i:integer;
S:longint;
begin
write('Nhap so N='); readln(N);
S:=0;
for i:=1 to N do S:=S+i;
write('Tong cua,'N,'so tu nhien dau tien S=',S);
readln
end.
Bt3:
Program Tinh_Giai_Thua;
var N,i:integer;
P:longint;
begin
write('N='); readln(N);
P:=1;
for i:=1 to N do P:=P*i;
writeln(N,'! =',P);
readln
end.
bt1:
Program Ba_canh_tam_giac;
uses crt;
var a,b,c:real;
begin
clrscr;
writeln('Nhap ba so a,b,c:'); readln(a,b,c);
If(a+b>c) and (b+c>a) and (a+c>b) then
writeln('a, b va c la 3 canh cua mot tam giac!');
else writeln('a, b va c khong la 3 canh cua mot tam giac!');
readln
end.
Bài 1:
*Dùng For..do
uses crt;
var n,i: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.
*Dùng While..do
uses crt;
var n,i:integer;
begin
clrscr;
write('Nhap n='); readln(n);
i:=1;
while i<=n do
begin
if n mod i=0 then write(i:4);
inc(i);
end;
readln;
end.
Bài 2:
*Dùng For..do
uses crt;
var n,i: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.
*Dùng While..do
uses crt;
var n,i:integer;
begin
clrscr;
write('Nhap n='); readln(n);
i:=1;
while i<=n do
begin
if (n mod i=0) and (i mod 2=0) then write(i:4);
inc(i);
end;
readln;
end.
Bài 3:
*Dùng For..do
uses crt;
var n,i,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('Tong cac uoc cua ',n,' la: ',t);
readln;
end.
*Dùng While..do
uses crt;
var n,i,t:integer;
begin
clrscr;
write('Nhap n='); readln(n);
t:=0;
i:=1;
while i<=n do
begin
if n mod i=0 then t:=t+i;
inc(i);
end;
writeln('Tong cac uoc cua ',n,' la: ',t);
readln;
end.
Bài 4:
*Dùng For..do
uses crt;
var i,dem:integer;
begin
clrscr;
dem:=0;
for i:=100 to 999 do
if i mod 3=0 then inc(dem);
writeln('So cac so co 3 chu so chia het cho 3 la: ',dem);
readln;
end.
*Dùng While..do
uses crt;
var i,dem:integer;
begin
clrscr;
dem:=0;
i:=100;
while i<=999 do
begin
if i mod 3=0 then inc(dem);
inc(i);
end;
writeln('So cac so co 3 chu so chia het cho 3 la: ',dem);
readln;
end.
Bài 5:
*Dùng For..do
uses crt;
var i,t,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('Tong cac so chan tu 1 toi ',n,' la: ',t);
readln;
end.
*Dùng While..do
uses crt;
var i,t,n:integer;
begin
clrscr;
write('Nhap n='); readln(n);
t:=0;
i:=1;
while i<=n do
begin
if i mod 2=0 then t:=t+i;
inc(i);
end;
writeln('Tong cac so chan tu 1 toi ',n,' la: ',t);
readln;
end.
Bài 6:
*Dùng For..do
uses crt;
var i,t,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('Tong cac so le tu 1 toi ',n,' la: ',t);
readln;
end.
*Dùng While..do
uses crt;
var i,t,n:integer;
begin
clrscr;
write('Nhap n='); readln(n);
t:=0;
i:=1;
while i<=n do
begin
if i mod 2=1 then t:=t+i;
inc(i);
end;
writeln('Tong cac so le tu 1 toi ',n,' la: ',t);
readln;
end.
Bài 7:
*Dùng For..do
uses crt;
var i,n:integer;
begin
clrscr;
write('Nhap n='); readln(n);
for i:=1 to n do
if i mod 5=0 then write(i:4);
readln;
end.
*Dùng While..do
uses crt;
var i,n:integer;
begin
clrscr;
write('Nhap n='); readln(n);
i:=1;
while i<=n do
begin
if i mod 5=0 then write(i:4);
inc(i);
end;
readln;
end.
Bài 8:
*Dùng For..do
uses crt;
var i,n,dem:integer;
begin
clrscr;
write('Nhap n='); readln(n);
dem:=0;
for i:=1 to n do
if (n mod i=0) and (i mod 2=1) then inc(dem);
writeln('So uoc le cua ',n,' la: ',dem);
readln;
end.
*Dùng While..do
uses crt;
var i,n,dem:integer;
begin
clrscr;
write('Nhap n='); readln(n);
dem:=0;
i:=1;
while i<=n do
begin
if (n mod i=0) and (i mod 2=1) then inc(dem);
i:=i+1;
end;
writeln('So uoc le cua ',n,' la: ',dem);
readln;
end.
Bài 9:
*Dùng For..do
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);
readln;
end.
*Dùng While..do
uses crt;
var i,n:integer;
begin
clrscr;
write('Nhap n='); readln(n);
writeln('Bang cuu chuong ',n,' la: ');
i:=1;
while i<=10 do
begin
writeln(n*i);
inc(i);
end;
readln;
end.
Bài 10:
*Dùng For..do
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 kt:=1;
if kt=0 then write(n,' la so nguyen to')
else write(n,' la hop so');
readln;
end.
*Dùng While..do
uses crt;
var i,n:integer;
begin
clrscr;
write('Nhap n='); readln(n);
i:=2;
while (n mod i<>0) and (i<=n) do
begin
inc(i);
end;
if i=n then writeln(n,' la so nguyen to')
else writeln(n,' la hop so');
readln;
end.
uses crt;var n: longint; chrn: string; valn,sum,max,i,preperror: byte;begin write('Nhap so can kiem tra: '); readln(n); str(n,chrn); for i:=1 to length(chrn) do begin val(chrn[i],valn,preperror); sum:=sum+valn; if max<valn then max:=valn; valn:=0 end; writeln('Ket qua: '); writeln(length(chrn)); writeln(sum); write(max); readln;end.uses crt;var n: longint; chrn: string; valn,sum,max,i,preperror: byte;begin write('Nhap so can kiem tra: '); readln(n); str(n,chrn); for i:=1 to length(chrn) do begin val(chrn[i],valn,preperror); sum:=sum+valn; if max<valn then max:=valn; valn:=0 end; writeln('Ket qua: '); writeln(length(chrn)); writeln(sum); write(max); readln;end.
Program HOC24;
var N:longint;
max,tg,t,d: integer;
Begin
write('Nhap N : '); readln(N);
max:=0;
while n<>0 do
begin
tg:=n mod 10;
d:=d+1;
t:=t+tg;
if tg>max then max:=tg;
n:=n div 10;
end;
writeln('So nguyen N co ',d,' chu so');
writeln('Tong cac chu so cua N la : ',t);
write('Chu so lon nhat cua N la :',max);
readln
end.