![](https://rs.olm.vn/images/avt/0.png?1311)
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.
![](https://rs.olm.vn/images/avt/0.png?1311)
![](https://rs.olm.vn/images/avt/0.png?1311)
Bài 1
Var s,i:integer;
tb:real;
Begin
Write('Nhap n = ');readln(n);
i:=1;
s:=0;
While i<=n do
Begin
s:=s+i;
i:=i+1;
End;
tb:=s/n;
Writeln('Tong la ',s);
Write('Trung binh la ',tb:10:2);
Readln;
End.
Bài 2
Var i,n,souoc:integer;
Begin
Write('Nhap n = ');readln(n);
i:=1;
While i <= n do
Begin
i:=i + 1;
If n mod i = 0 then souoc:=souoc + 1;
End;
If souoc = 1 then write(n,' la so nguyen to')
Else write(n,' khong la so nguyen to');
Readln;
End.
![](https://rs.olm.vn/images/avt/0.png?1311)
uses crt;
var i,j,kt:integer;
begin
clrscr;
for i:=100 to 1 do write(i:4);
writeln;
for i:=2 to 100 do
begin
kt:=0;
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.
![](https://rs.olm.vn/images/avt/0.png?1311)
program Le_Nho_Hon_Hoac_Bang_n;
uses crt;
var
n, i: integer;
begin
clrscr;
write('Nhap vao mot so nguyen duong n: ');
readln(n);
while n <= 0 do
begin
writeln('So ban nhap khong hop le. Xin vui long nhap lai: ');
readln(n);
end;
clrscr;
writeln('Cac so le nho hon hoac bang ', n, ' la:');
i := 1;
while i <= n do
begin
if i mod 2 <> 0 then
writeln(i);
i := i + 1;
end;
readln;
end.
![](https://rs.olm.vn/images/avt/0.png?1311)
program im_14424;
uses crt;
var A: array[1..1000000] of longint;
S: longint;
i: integer;
begin
clrscr;
write('Nhap vao n: ');
readln(n);
S:=0;
for i:=1 to n do
begin
write('Nhap phan tu thu`,i,':');
readln(A[i]);
S:=S+i;
end;
readln
end.
![](https://rs.olm.vn/images/avt/0.png?1311)
#include <bits/stdc++.h>
using namespace std;
long long n,dem,i;
int main()
{
freopen("bl1.inp","r",stdin);
freopen("bl1.out","w",stdout);
cin >> n;
for( i = 2; i <= n; i++)
{
dem = 0;
while(n % i == 0)
{
++dem;
n=n/i;
}
if(dem)
{
cout<<i;
if (dem>1) cout <<"^"<<dem;
if (n>i){
cout <<" * ";
}
}
}
return 0;
}
![](https://rs.olm.vn/images/avt/0.png?1311)
Câu 1:
uses crt;
var n,i,dem,j,kt1,kt2,a,b,kt:integer;
begin
clrscr;
write('Nhap n='); readln(n);
dem:=0;
if n mod 2=1 then
begin
a:=2;
b:=n-a;
kt:=0;
for i:=2 to trunc(sqrt(b)) do
if b mod i=0 then kt:=1;
if kt=0 then inc(dem);
end
else begin
for i:=2 to n div 2 do
begin
a:=i;
b:=n-i;
kt1:=0;
kt2:=0;
for j:=2 to trunc(sqrt(a)) do
if a mod j=0 then kt1:=1;
for j:=2 to trunc(sqrt(b)) do
if b mod j=0 then kt2:=1;
if (kt1=0) and (kt2=0) then inc(dem);
end;
end;
writeln('So cach phan tich ',n,' thanh tong hai so nguyen to la: ',dem);
readln;
end.
Câu 2:
uses crt;
var n,x:integer;
{-----------------ham-kiem-tra-nguyen-to-----------------}
function ktnt(x:integer):boolean;
var kt:boolean;
i:integer;
begin
kt:=true;
for i:=2 to trunc(sqrt(x)) do
if x mod i=0 then
begin
kt:=false;
break;
end;
if kt=true then ktnt:=true
else ktnt:=false;
end;
{---------------ham-kiem-tra-so-doi-xung---------------}
function ktdx(x:integer):boolean;
var kt:boolean;
d,i:integer;
st:string;
begin
str(x,st);
d:=length(st);
kt:=true;
for i:=1 to d do
if st[i]<>st[d-i+1] then
begin
kt:=false;
break;
end;
if kt=true then ktdx:=true
else ktdx:=false;
end;
{--------------chuong-trinh-chinh---------------}
begin
clrscr;
repeat
write('Nhap n='); readln(n);
until n>0;
if (ktnt(n)=true) and (ktdx(n)=true) then writeln(n,' la so nguyen to doi xung')
else writeln(n,' khong la so nguyen to doi xung');
x:=n+1;
repeat
x:=x+1;
until (ktnt(x)=true) and (ktdx(x)=true);
writeln('So nguyen to doi xung nho nhat lon hon ',n,' la: ',x);
readln;
end.
![](https://rs.olm.vn/images/avt/0.png?1311)
Var n, i : integer;
Begin
write(‘Nhập số n = ‘);
readln(n);
i := 2;
while (n mod i <> 0) and (i < n) do
i := i + 1;
if i < n then write(n, ‘ là số nguyên tố.’)
else write(n, ‘ là hợp.’)
readln;
End.
![](https://rs.olm.vn/images/avt/0.png?1311)
uses crt;
var n,kt,i,n1,i1:integer;
begin
clrscr;
write('nhap n='); readln(n);
kt:=0;
for i:=2 to trunc(sqrt(n)) do
if n mod i=0 then kt:=1;
if kt=0 then writeln(n,' khong the phan tich thanh thua so nguyen to');
if kt=1 then begin
write(n,'=');
n1:=n;
i1:=2;
repeat
while n1 mod i1<>0 do
i1:=i1+1;
write(i1);
n1:=n1 div i1;
if n1>1 then write('*');
until n1=1;
end;
readln;
end.
var n,k:int64;
i,d:longint;
begin
readln(n);
k:=trunc(Sqrt(n));
i:=2;
res:=1;
while i<=k do
begin
d:=0;
while n mod i=0 do
begin
write(i);
n:=n div i;
if n>1 then write('*');
inc(d);
end;
k:=trunc(sqrt(N));
i:=i+1;
end;
if n>1 then write(n);
readln;
end.