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.
#include <bits/stdc++.h>
using namespace std;
long long n,i,x,t,dem,j;
int main()
{
cin>>n;
x=n;
t=0;
while (n>0)
{
t=t+n%10;
n=n/10;
}
cout<<t;
dem=0;
for (i=2; i<=x; i++)
{
bool kt=true;
for (j=2; j*j<=i; j++)
if (i%j==0) kt=false;
if (kt==true) dem++;
}
cout<<dem;
return 0;
}
def kiem_tra_nguyen_to(n):
if n < 2:
return False
for i in range(2, int(n ** 0.5) + 1):
if n % i == 0:
return False
return True
def kiem_tra_nguyen_to_cung_nhau(m, n):
if kiem_tra_nguyen_to(m) and kiem_tra_nguyen_to(n):
return True
return False
M = int(input("Nhập số M: "))
N = int(input("Nhập số N: "))
if kiem_tra_nguyen_to_cung_nhau(M, N):
print("Hai số", M, "và", N, "là hai số nguyên tố cùng nhau.")
else:
print("Hai số", M, "và", N, "không phải là hai số nguyên tố cùng nhau.")
uses crt;
var n,i,dem,j,t:integer;
kt:boolean;
begin
clrscr;
readln(n);
t:=0;
for i:=2 to n do
begin
kt:=true;
for j:=2 to i-1 do
if i mod j=0 then kt:=false;
if kt=true then
begin
write(i:4);
t:=t+i;
end;
end;
writeln;
writeln(t);
readln;
end.
const fi='snt.inp';
fo='snt.out';
var f1,f2:text;
n,i:integer;
a,b:array[1..100]of integer;
{-----------------ham-kiem-tra-so-nguyen-to-------------------------}
function ktra(x:integer):boolean;
var kt:boolean;
i:integer;
begin
kt:=true;
for i:=2 to x-1 do
if x mod i=0 then kt:=false;
if kt=true then ktra:=true
else ktra:=false;
end;
{---------------------chuong-trinh-chinh---------------------}
begin
assign(f1,fi); reset(f1);
assign(f2,fo); rewrite(f2);
readln(f1,n);
for i:=1 to n do
readln(f1,a[i],b[i]);
for i:=1 to n do
if ktra(a[i]-b[i])=true then writeln(f2,'YES')
else writeln(f2,'NO');
close(f1);
close(f2);
end.
uses crt;
var i,n,t,j,kt:integer;
begin
clrscr;
readln(n);
t:=0;
for i:=2 to n do
if n mod i=0 then
begin
kt:=0;
for j:=2 to trunc(sqrt(i)) do
if i mod j=0 then kt:=1;
if kt=0 then t:=t+i;
end;
write(t);
readln;
end.
câu 1
Program Nguyen_to;
Var n,i:integer;
Function NT(n:integer):Boolean;
Var ok: Boolean;
i: integer;
Begin ok:=true;
for i:=2 to n-1 do if (n mod i)= 0 then ok:=ok and false;
if n < 2 then NT:=false else NT:=ok;
End;
Begin Write('Nhap n: ');
Readln(n); i:=n;
Repeat i:=i+1;
Until NT(i);
Write('So nguyen to nho nhat lon hon ',n, 'la: ',i);
Readln End.
câu 2
uses crt;
const so: set of char=['0','1','2','3','4','5','6','7','8','9'];
var a:array[1..100] of integer;
st,b:string;
c,l,i,n,j:integer;
s, Max: integer;
begin clrscr;
write('Nhap xau:');
readln(st);
l:=length(st);
i:=1;
n:=0;
repeat if (st[i] in so) then begin b:='';
repeat b:=b+st[i];
inc(i);
until (not(st[i] in so)) or (i>l);
inc(n);
val(b,a[n],c);
end;
inc(i);
until i>l;
Max:=a[1];
for i:=2 to n do If Max<A[i] Then Max:=A[i];
Writeln('Phan tu lon nhat cua mang:', Max);
readln;
end.
uses crt;
var x:int64;
kt,i,n,d,j,kt1,k:integer;
a:array[1..100]of longint;
st:string;
ktnt:boolean;
begin
clrscr;
write('x='); readln(x);
if (0<x) and (x<1000000000) then
begin
kt:=0;
for i:=2 to trunc(sqrt(x)) do
if x mod i=0 then kt:=1;
if kt=0 then
begin
str(x,st);
d:=length(st);
for j:=1 to d do
val(st[j],a[j],n);
ktnt:=false;
for j:=1 to d do
begin
kt1:=0;
for k:=2 to a[j]-1 do
if a[j] mod k=0 then kt1:=1;
if kt1=0 then ktnt:=true
else ktnt:=false;
end;
if ktnt=true then writeln(x*2)
else writeln(x div 2);
end
else writeln(x div 2);
end
else writeln('vui long nhap lai');
readln;
end.