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.
Bạn kham khảo bài của mình nhé!
Program nhap_so_n;
Uses crt;
Var i,n,s:integer;
Begin clrscr;
Write('Nhap so n= ');Readln(n);
S:=0;
For i:=1 to n do
If i mod 2 = 0 do S:=S+i;
Writeln;
Write('tong cac so chan la ',S);
Readln;
End.
Mình chúc bạn học tốt!
#include <bits/stdc++.h>
using namespace std;
long long i,n,s;
int main()
{
cin>>n;
s=0;
for (i=1; i<=n; i++)
if (i%2==0) s=s+i;
cout<<s;
return 0;
}
uses crt;
var s:real;
i,n:integer;
begin
clrscr;
readln(n);
s:=0;
for i:=1 to n do
s:=s+1/(i*(i+2));
writeln(s:4:2);
readln;
end.
Program HOC24;
var i,n: integer;
s: longint;
begin
write('Nhap n : '); readln(n);
s:=0;
for i:=1 to n do if i mod 2=0 then s:=s+i;
write('S = ',s);
readln
end.
pascal
program sum_of_evens;
var
i, n, sum: integer;
begin
write('Enter a positive integer: ');
readln(n);
sum := 0;
for i := 2 to n step 2 do
begin
sum := sum + i;
end;
writeln('The sum of even numbers from 2 to ', n, ' is ', sum);
end.
uses crt;
var n,m,i,dem,t,t1,d1:integer;
//chuongtrinhcon
function ktnt(var n:integer):boolean;
var i:integer;
kt:boolean;
begin
kt:=true;
for i:=2 to trunc(sqrt(n)) do
if n mod i=0 then kt:=false;
if (kt=true) then ktnt:=true
else ktnt:=false;
end;
//chuongtrinhchinh
begin
clrscr;
readln(n,m);
if (ktnt(n)=true) then writeln(n,' la so nguyen to')
else writeln(n,' ko la so nguyen to');
dem:=0;
t:=0;
for i:=2 to n do
if (ktnt(i)=true) then
begin
write(i:4);
t:=t+i;
dem:=dem+1;
end;
writeln;
writeln(t,' ',dem);
t1:=0;
d1:=0;
for i:=n to m do
if ktnt(i)=true then
begin
write(i:4);
t1:=t1+i;
inc(d1);
end;
writeln;
writeln(t1,' ',d1);
readln;
end.
uses crt;
var s:real;
i,n:integer;
begin
clrscr;
readln(n);
s:=0;
for i:=1 to n do
s:=s+(n*(n+1))/((n+2)*(n+3));
writeln(s:4:2);
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.
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.
uses crt;
var i,n:integer;
s:longint;
begin
clrscr;
write('nhap n:');readln(n);
s:=0;
for i:=1 to n do
if i mod 2=1 then s:=s+i
else s:=s-i;
writeln('s= ',s);
readln;
end.