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 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 TongUoc;
uses crt;
var
N, i, Tong: integer;
begin
clrscr;
Tong := 0;
write('Nhap so tu nhien N: ');
readln(N);
// Tinh tong cac uoc cua N
for i := 1 to N do
begin
if N mod i = 0 then
begin
Tong := Tong + i;
end;
end;
writeln('Tong cac uoc cua ', N, ' la: ', Tong);
readln;
end.
Câu 3:
Var i,n:integer:
Begin
Write('n = ');readln(n);
Write('Cac uoc cua n la ');
For i:=1 to n do
If n mod i = 0 then write(i:8);
Readln
End.
Câu 4
Var i,n:integer:
Begin
Write('n = ');readln(n);
Write('Cac so le nho hon n la ');
For i:=1 to n - 1 do
If i mod 2 <> 0 then write(i:8);
Readln
End.
Var array:[1..1000] of integer;
i,n:integer;
Begin
Write('n = ');readln(n);
For i:=1 to n do
Begin
Write('Nhap so thu ',i,' = ');readln(a[i]);
End;
Write('Cac so vua nhap la ');
For i:=1 to n do write(a[i]:8);
Readln
End.
Tham khảo:
program tim_uoc;
uses crt;
var n,i:integer;
begin
clrscr;
write('Nhap n: ');readln(n);
if (n<0) then
begin
writeln('So nhap vao khong thoa man.');
write('Nhap lai n: ');readln(n);
end;
writeln('Cac uoc so cua ',n,' tu 1 den ',n,' la: ');
for i:=1 to n do
if ( (n mod i) = 0 ) then write(i,' ');
readln;
end.
#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;
}
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.