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;
int main()
{
long long n,dem=0,s=0;
cin >> n;
for (long long i=1;i<=n;i+=2){
dem++;
s+=i;
}
cout << "tu 0 den n co: " << dem << " so le" << endl;
cout << "tong cac so le do la: " << s;
return 0;
#include <bits/stdc++.h>
using namespace std;
int main()
{
long long n,dem=0,s=0;
cin >> n;
for (long long i=1;i<=n;i+=2){
dem++;
s+=i;
}
cout << "tu 0 den n co: " << dem << " so le" << endl;
cout << "tong cac so le do la: " << s;
return 0;
}
var i,n,d:integer;
s:longint;
begin
write('n = ');readln(n);
for i:=1 to n do
if i mod 2 <> 0 then
begin
d:=d+1;
s:=s+i;
end;
writeln('co ',d,' so le');
write('tong cac so le la ',s);
readln;
end.
program tim_n;
uses crt;
var tong,n,i:word;
begin
clrscr;
n:=1;tong:=0;
while tong<500 do
begin
for i:=1 to n do tong:=tong+i;
if tong<500 then begin tong:=0;n:=n+1;end
else n:=n-1;
end;
write('so n thoa man dieu kien la:',n);
readln;
end.
uses crt;
var i,n,t:integer;
begin
clrscr;
write('Nhap n='); readln(n);
t:=0;
for i:=1 to 500 do
begin
t:=t+i;
if t>500 then
begin
writeln(i);
break;
end;
end;
readln;
end.
uses crt;
var n,t:integer;
begin
clrscr;
n:=0;
t:=0;
while t<=3500 do
begin
n:=n+1;
t:=t+n;
end;
writeln(t-n);
readln;
end.
câu 1:
uses crt;
var p,i:integer;
begin
clrscr;
p:=1;i:=1;while i<=5 do
begin
p:=p*i;i:=i+1;
end;
write(p);
readln;
end.
bai 2:
uses crt;var p,i:integer;begin clrscr; p:=1; i:=0; while i <=10 do begin
i:=i+1; if (i mod 2<>0) then p:=p*i; end; write(p); readln;end. bai 3:
uses crt;var n,i,p:integer;begin clrscr; write('nhap n: '); readln(n); i:=1; p:=1; while i<=n do begin if i mod 2=0 then p:=p*i; i:=i+1; end; write(p); readln;end.
Var n,s:integer;
Begin
n:=0;
While s<=1000 do
begin
n:=n+1;
s:=s+n;
End;
Write('Tong dau tien lon hon 1000 la ',s);
Readln;
End.
Tham khảo link: https://hoc24.vn/cau-hoi/viet-chuong-trinh-tinh-tong-cua-n-so-tu-nhien-dau-tien-sao-cho-tong-nho-hon-hoac-bang-1000giup-minh-voi-thu-6-thi-roi.180444032537
Câu 1:
Program HOC24;
var i,p: integer;
t: longint;
begin
write('Nhap P: '); readln(p);
t:=0;
for i:=1 to p do if i mod 2<>0 then t:=t+i;
write('Tong cac so le la: ',t);
readln
end.
Program HOC24;
var i,n: integer;
tong,tich: longint;
begin
write('Nhap N: '); readln(n);
tong:=0; tich:=1;
for i:=1 to n do
begin
tong:=tong+i;
tich:=tich*i;
end;
writeln('Tong la: ',tong);
write('Tich la: ',tich);
readln
end.
program TinhTongTichTu1DenN;
var n, i: integer;
tong, tich: longint;
begin
tong := 0;
tich := 1;
write('Nhap vao n: ');
readln(n);
for i := 1 to n do
begin
tong := tong + i;
tich := tich * i;
end;
writeln('Tong cac so tu 1 den ', n, ': ', tong);
writeln('Tich cac so tu 1 den ', n, ': ', tich);
readln;
end.
var i,n,s:longint;
begin
readln(n);
s:=0;
for i:=4 to n do s:=s+i;
writeln(s);
end.
uses crt;
var n,t:integer;
begin
clrscr;
n:=5;
t:=0;
while t<=4000 do
begin
t:=t+n;
n:=n+1;
end;
writeln(t-n);
readln;
end.