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.
Cau 1:
var i,dem:integer;
function ngto(n:longint):boolean;
var bo:boolean;
i:longint;
begin
bo:=true;
for i:=2 to n-1 do
if n mod i=0 then bo:=false;
if n>1 then ngto:=bo else ngto:=false;
end;
begin
for i:=2 to 100 do
if ngto(i) then dem:=dem+i;
write(dem);
readln;
end.
Cau 2:
var i,dem,n:longint;
begin
read(n);
dem:=1;
for i:=1 to n do
dem:=dem*i;
write(dem);
readln;
end.
program TongSoChan;
var
n, i, x, tong: integer;
begin
write('Nhap so nguyen n: ');
readln(n);
tong := 0;
for i := 1 to n do
begin
read(x);
if x mod 2 = 0 then
tong := tong + x;
end;
writeln('Tong cac so chan la: ', tong);
readln;
end.
n = int(input('Nhập số n: '))
sum = 0
i = 1
while i <= n:
if i % 2 == 0:
sum += i
print(i, end=' ')
i += 1
print()
print('Tổng các số chẵn từ 1 đến n là:', sum)
n = int(input('Nhập số n: '))
sum = 0
i = 1
while i <= n:
if i % 2 == 0:
sum += i
print(i, end=' ')
i += 1
print()
print('Tổng các số chẵn từ 1 đến n là:', sum)
#include <bits/stdc++.h>
using namespace std;
long long n,i,t;
int main()
{
cin>>n;
t=0;
for (i=1; i<=n; i++)
if (i%3==0) t=t+i;
cout<<t;
return 0;
}
def is_coprime(a, b):
"""Hàm ktra a và b có phải là nguyên tố cùng nhau"""
while b:
a, b = b, a % b
return a == 1
n = int(input("Nhập stn n: "))
count = 0
for i in range(1, n+1):
if is_coprime(i, n):
count += 1
print(f"Số lượng số nguyên tố cùng nhau với n là {count}.")
n = int(input())
for i in range(1, n+1):
print(i, end=" ")