Những câu hỏi liên quan
Bùi Thị Châu Loan
Xem chi tiết
Nguyễn Lê Phước Thịnh
8 tháng 3 2021 lúc 13:55

uses crt;

var n,i:integer;

m:real;

begin

clrscr;

repeat

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

until (1<=n) and (n<=30000);

m:=0;

for i:=1 to n do 

  m:=m+sqrt(i);

writeln('m=',m:4:2);

readln;

end.

Bình luận (1)
Quỳnh Hoa
Xem chi tiết
Nguyễn Lê Phước Thịnh
19 tháng 10 2021 lúc 23:22

#include <bits/stdc++.h>

using namespace std;

long n,i,dem,t;

int main()

{

cin>>n;

dem=0;

t=0;

for (i=1; i<=n;i++)

if (n%i==0) 

{

dem++;

t=t+i;

}

cout<<dem<<" "<<t;

return 0;

}

Bình luận (0)
nuinuini
Xem chi tiết
nguyen thi be
Xem chi tiết
Nguyễn Lê Phước Thịnh
29 tháng 12 2020 lúc 11:58

uses crt;

var n,i,t:integer;

begin

clrscr;

repeat

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

until n>0;

t:=0;

for i:=1 to n do 

  if i mod 3=0 then t:=t+i;

writeln('Tong cac so chia het cho 3 trong khoang tu 1 toi ',n,' la: ',t);

readln;

end.

Bình luận (0)
Chouu11
Xem chi tiết
Kiều Vũ Linh
16 tháng 5 2023 lúc 7:39

Var n,sc,sl,i:longint;

Begin

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

Write('Cac so tu 1 den ',n,' la ');

For i:=1 to n do

Write(i:8);

Writeln;

For i:=1 to n do

Begin

If i mod 2 = 0 then sc:=sc+i

Else sl:=sl+i;

End;

Writeln('Tong cac so chan la ',sc);

Write('Tong cac so le la ',sl);

Readln

End.

Bình luận (0)
dinhnguyentuhuy
Xem chi tiết
Nguyễn Lê Phước Thịnh
31 tháng 1 2021 lúc 8:53

uses crt;

var n,i,d,dem,kt,t,kt1,t1,t2,t3,max,min,x,j:integer;   

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

st:string;

begin

clrscr;

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

str(n,st);

d:=length(st);

for i:=1 to d do 

val(st[i],a[i],x);

dem:=1;

b[1]:=a[1];

for i:=1 to d do 

begin     

kt:=0;     

for j:=1 to dem do       

if a[i]=b[j] then kt:=1;     

if kt=0 then       

begin           

inc(dem);           

b[dem]:=a[i];       

end; 

end;

writeln('Cac chu so cua ',n,' la: ');

for i:=1 to dem do 

write(b[i]:4);

writeln;

t:=0;

for i:=1 to d do 

t:=t+a[i];

writeln('Tong cac chu so cua ',n,' la: ',t);

kt1:=0;

for i:=2 to trunc(sqrt(t)) do 

if t mod i=0 then     

begin       

kt1:=1;       

break;     

end;

if (kt1=0) and (t>1) then writeln(t,' la so nguyen to')

else writeln(t,' khong la so nguyen to');

writeln('Cac chu so o vi tri le cua ',n,' la: ');

t1:=0;

for i:=1 to d do 

if i mod 2=1 then     

begin       

write(a[i]:4);       

t1:=t1+a[i];     

end;

writeln;

writeln('Tong cac chu so o vi tri le la: ',t1);

if trunc(sqrt(t1))=sqrt(t1) then writeln(t1,' la so chinh phuong')

else writeln(t1,' khong la so chinh phuong');

writeln('Cac chu so o vi tri chan cua ',n,' la: ');

t2:=0;

for i:=1 to d do 

if i mod 2=0 then     

begin       

write(a[i]:4);       

t2:=t2+a[i];     

end;

writeln('Tong cac chu so o vi tri chan la: ',t2);

t3:=0;

for i:=1 to t2 do 

if t2 mod i=0 then t3:=t3+i;

if (t3=t2) and (t2>0) then writeln(t2,' la so hoan hao')

else writeln(t2,' khong la so hoan hao');

max:=a[1];

min:=a[1];

for i:=1 to d do 

begin     

if max<a[i] then max:=a[i];     

if min>a[i] then min:=a[i]; 

end;

writeln('Chu so lon nhat cua ',n,' la: ',max);

writeln('Chu so nho nhat cua ',n,' la: ',min);

writeln('Tong cua chung la: ',max+min);

readln;

end.

Bình luận (0)
Bao Duong
Xem chi tiết
dffhb
Xem chi tiết
Minh Lệ
26 tháng 2 2021 lúc 17:52

Program HOC24;

var a: array[1..250] of integer;

i,n: integer;

t: longint;

begin

write('Nhap N: '); readln(N);

t:=0;

for i:=1 to n do if i mod 2=1 then t:=t+i;

write('Tong cac phan tu o vi tri le la: ',t);

readln

end.

Bình luận (0)
Nguyễn Lê Phước Thịnh
26 tháng 2 2021 lúc 21:26

uses crt;

var a:array[1..250]of integer;

i,n,t:integer;

begin

clrscr;

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

for i:=1 to n do 

begin

write('A[',i,']='); readln(a[i]);

end;

t:=0;

for i:=1 to n do 

  if (a[i] mod 2<>0) and (i mod 2=0) then t:=t+a[i];

writeln(t);

readln;

end.

Bình luận (0)
‎‎‎            ‎
Xem chi tiết
Nguyễn Lê Phước Thịnh
18 tháng 12 2021 lúc 0:41

#include <bits/stdc++.h>

using namespace std;

long long m,n,i,t;

int main()

{

cin>>m>>n;

t=0;

for (i=m; i<=n; i++)

if (i%15==0) t=t+i;

cout<<t;

return 0;

}

Bình luận (0)