Viết chương trình tính tích từ 1 đến 50
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 i,s;
int main()
{
s=1;
for (i=5; i<=50; i++) s=s*i;
cout<<s;
return 0;
}
Uses crt;
Var S,i : integer;
BEGIN
clrscr;
S:= 0;
For i:=1 to 50 do
S:= S+i;
Writeln (' Vay tong cua cac so tu 1 den 50 la ', S);
Readln
END.
program TinhTong;
var
Tong, i: integer;
begin
Tong := 0;
for i := 1 to 50 do
begin
Tong := Tong + i;
end;
writeln('Tong tu 1 den 50 la: ', Tong);
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.
1.
Var i ,n : integer;
S , T : real;
Begin
Write ('n:') ;
Read (n) ;
S:= 0;
T:= 1;
For i:= 1 to n do
S:= S + i;
T:= T * i;
Writeln (' Tong cua ' ,n,' , S );
Writeln (' Tich của ' ,n,', T );
Readln;
End.
2.
program SumAndProductOfNumbers;
var
n, m, i, sum, product: integer;
begin
writeln('Enter the values of n and m: ');
readln(n, m);
sum := 0;
product := 1;
for i := n to m do
begin
sum := sum + i;
product := product * i;
end;
writeln('The sum of numbers from ', n, ' to ', m, ' is: ', sum);
writeln('The product of numbers from ', n, ' to ', m, ' is: ', product);
end.
uses crt;
var i:integer;
s:real;
begin
clrscr;
s:=1;
for i:=1 to 100 do
s:=s*i;
writeln(s:0:0);
readln;
end.
Bài 1:
uses crt;
var i,s:integer;
begin
clrscr;
s:=0;
for i:=10 to 50 do
if i mod 2=0 then s:=s+i;
writeln(s);
readln;
end.
Bài 2:
uses crt;
var a,i,n:integer;
begin
clrscr;
write('Nhap n='); readln(n);
a:=0;
for i:=1 to n do
a:=a+i*(i+2);
writeln(a);
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.
Program HOC24;
var i: byte;
t: longint;
begin
t:=1;
for i:=1 to 50 do t:=t*i;
write('Ket qua la: ',t);
readln
end.
Tham khảo:
Program bai_tap;
Uses crt;
Var i:integer;
Begin
clrscr;
For i:=1 to 50 writeln(i);
readln;
End.