Những câu hỏi liên quan
Ngọc Nguyễn Thái Khánh
Xem chi tiết
nguyễn an phát
29 tháng 3 2021 lúc 17:24

program tim_tong_va_tich;

uses crt;

var n,i:integer;

tong,tich:longint;

a:array[1..100]of integer;

begin

write('nhap so n:');readln(n);

i:=1;tich:=1;tong:=0;

while i<=n do

begin

write('nhap phan tu a[',i,']:');readln(a[i]);

tong:=tong+a[i];tich:=tich+a[i];

i:=i+1;

end;

writeln('tong cua cac so tren la:',tong);

writeln('tich cua cac so tren la:',tich);

readln;

end.

Bình luận (0)
Võ Thái An Bình
Xem chi tiết
Nguyên Hưng Trần
26 tháng 7 2021 lúc 18:37

Uses crt;
var i,n,uoc,j,tam:longint;
Begin
clrscr;
readln(n);uoc:=0;tam:=0;
for i:= 1 to n do if n mod i = 0 then inc(uoc);
if uoc = 2 then write(n,' la so nguyen to')
 else for i:= 2 to n do if n mod i = 0 then
   begin
   tam:=0;
   for j:= 1 to i do if i mod j = 0 then inc(tam);
   if tam = 2 then write(i,'  ');
   end;
readln;
end.

Có chỗ nào sai thì bảo mình

Bình luận (1)
TKT VN
Xem chi tiết
nguyễn an phát
1 tháng 9 2021 lúc 11:21

program bai_1;
uses crt;
var i,n,j,d,dem:word;
begin
  clrscr;
  repeat
    write('nhap n:');readln(n);
    if (n<=0)or(n>=10000)then writeln('so ban nhap khong hop le, ban hay nhap lai:');
  until (n>0)and(n<10000);
  writeln('cac uoc so la so tu nhien cua ',n,' la:');
  for i:=1 to n do
  if n mod i=0 then write(i,'    ');
  writeln;
  dem:=0;
  for i:=2 to n do
  begin
    d:=0;
    for j:=2 to i div 2 do
    if i mod j=0 then inc(d);
    if (d=0)and(n mod i=0)then inc(dem);
  end;
  if dem>0 then writeln('cac uoc so la so nguyen to cua ',n,' la:');
  begin
    d:=0;
    for j:=2 to i div 2 do
    if i mod j=0 then inc(d);
    if (d=0)and(n mod i=0)then write(i,'    ');
  end;
  if dem=0 then write(0);
  readln;
end.

 

Bình luận (0)
nh78844
Xem chi tiết
Nguyễn Lê Phước Thịnh
18 tháng 2 2022 lúc 15:38

uses crt;

var n,i:integer;

begin

clrscr;

readln(n);

for i:=1 to n do write(i:4);

readln;

end.

Bình luận (0)
Nguyễn Hoàng Duy
22 tháng 3 2023 lúc 18:26

n = int(input("Nhập vào số n: "))

if n <= 0:
    print("n phải lớn hơn 0")
else:
    for i in range(1, n+1):
        print(i)

Bình luận (0)
Nguyễn Thị Tươi
Xem chi tiết
Thanh Hiền Hồ
Xem chi tiết
Ngô Bá Hùng
16 tháng 4 2023 lúc 20:25

program TinhTongTu1DenN;
var
  N, i, tong: integer;
begin
  write('Nhap so N: ');
  readln(N);
  
 
  tong := 0;
  for i := 1 to N do
    tong := tong + i;
  
  writeln('Tong cac so tu 1 den ', N, ' la: ', tong);
  readln; 
end.

 

Bình luận (0)
Edward Paros
16 tháng 4 2023 lúc 22:08

N = int(input("Nhập số tự nhiên N: "))
tong = 0
for i in range(1, N+1):
    tong += i
print("Tổng các số từ 1 đến ", N, " là: ", tong)

 

Bình luận (0)
lê anh tuấn
Xem chi tiết
Hương Mai
Xem chi tiết
Kiều Vũ Linh
28 tháng 4 2022 lúc 6:42

Var i,n:integer;

p:longint;

Begin

Write('Nhap n = ');readln(n);

p:=0;

For i:=2 to n do p:=p*i;

Write('Tich la ',p);

Readln;

End.

Bình luận (0)
Kiều Vũ Linh
28 tháng 4 2022 lúc 6:43

Var i,n:integer;

p:longint;

Begin

Write('Nhap n = ');readln(n);

p:=1;

For i:=2 to n do p:=p*i;

Write('Tich la ',p);

Readln;

End.

Bình luận (0)
Lê Xuân Hoa
Xem chi tiết
Nguyễn Hoàng Duy
30 tháng 3 2023 lúc 21:30

program SumOfNumbers;

uses crt;

var
  n, i, sum: integer;
  numbers: array[1..100] of integer;

begin
  clrscr;
  write('Enter n: ');
  readln(n);

  // Tạo mảng các số tự nhiên từ 1 đến n
  for i := 1 to n do
    numbers[i] := i;

  // Tính tổng các số tự nhiên từ 1 đến n
  sum := 0;
  for i := 1 to n do
    sum := sum + numbers[i];

  writeln('The sum of the first ', n, ' natural numbers is: ', sum);
  readln;
end.

Bình luận (0)