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.
Câu 1:
program Tinhtong:
var
n, i, sum: integer;
begin
write('Nhap n: ');
readln(n);
sum := 0;
for i := 2 to n do
begin
if i mod 2 = 0 then
begin
sum := sum + i;
end;
end;
writeln('Tong cac so chan tu 2 toi ', n, ' la ', sum);
readln;
end.
Câu 2:
program Tinhtong:
var
n, i, sum: integer;
begin
write('Nhap n: ');
readln(n);
sum := 0;
for i := 1 to n do
begin
if i mod 2 = 1 then
begin
sum := sum + i;
end;
end;
writeln('Tong cac so le tu 1 toi ', n, ' la ', sum);
readln;
end.
int main()
{
int n;
long s;
s=0;
i=1;
printf("\nSo n la: ");
scanf("%d",&n);
for(int i=1; i<=n; i++)
{
s=s+i;
}
printf("\nTổng %d là %ld: ", n, s);
}
Câu 6:
uses crt;
var n,i:integer;
begin
clrscr;
readln(n);
for i:=1 to n do
if n mod i=0 then write(i:4);
readln;
end.
5:
uses crt;
var n,i,dem:integer;
begin
clrscr;
readln(n);
dem:=0;
for i:=0 to n do
if i mod 2=1 then
begin
write(i:4);
dem:=dem+1;
end;
writeln;
writeln(dem);
readln;
end.
Uses crt;
var n,i,s: integer;
begin clrscr;
readln(n);
for i:=1 to n do s:=s+1/i;
writeln(s);
readln;
end.
Câu 1:
uses crt;
var n,i:integer;
s:real;
begin
clrscr;
write('Nhap n='); readln(n);
s:=1;
for i:=1 to n do
s:=s*i;
writeln(s);
readln;
end.
Câu 2:
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.
-Python:
n=int(input('n= '))
t=0
for i in range(1,2*n):
if i%2!=0:
t+=i**3
print('Tong=',t)
#include <bits/stdc++.h>
using namespace std;
long long i,n,t;
int main()
{
cin>>n;
t=0;
for (i=1; i<=2*n; i++)
if (i%2!=0) t+=pow(i,3);
cout<<t;
return 0;
}
#include <bits/stdc++.h>
using namespace std;
long long i,n;
double s;
int main()
{
cin>>n;
s=0;
for (i=1; i<=n; i++)
s=s+((1*1.0)/(2*(i*1.0+1*1.0)));
cout<<fixed<<setprecision(2)<<s;
return 0;
}
program TongN;
var
n, i, tong: integer;
begin
tong := 0;
writeln('Nhap so nguyen duong N: ');
readln(n);
i := 0;
while i < n do
begin
i := i + 1;
tong := tong + i;
end;
writeln('Tong cac so tu 1 den ', n, ' la ', tong);
readln;
end.
Sửa đề: S=1/1+1/2+1/3+...+1/n
uses crt;
var n,i:integer;
s:real;
begin
clrscr;
write('Nhap n='); readln(n);
s:=0;
for i:=1 to n do
s:=s+1/i;
writeln(s:4:2);
readln;
end.
program tong;
uses crt;
var n,i:integer;
t:longint;
begin
clrscr;
write('nhap n:'); readln(n);
t:=0;
for i:=1 to n do
t:=t+1/i;
writeln(t);
readln;
end.
1:
uses crt;
var n,i,t:integer;
begin
clrscr;
readln(n);
t:=0;
for i:=1 to n do
t:=t+i*i;
write(t);
readln;
end.
2
program bt2;
var i,n,t:integer;
begin
readln(n);
s:=0;
for i:=1 to n do
if i mod 2 = 1 then s:=s+i;
readln;
end.