Lập trình đơn giản

Bastkoo

Viết chương trình in các số hoàn hảo từ 1 đến 100 ra màn hình

Phần thưởng là 2GP cho bạn có câu trả lời đúng và nhanh .

Luân Đào
4 tháng 4 2019 lúc 17:58

program sohoanhao;

uses crt;

var i,j, tong: integer;

begin

clrscr;

for i:=1 to 100 do

begin

tong:=0;

for j:= i-1 downto 1 do

if i mod j = 0 then tong:= tong + j;

if tong = i then write(i,',');

end;

readln

end.

Bình luận (3)
Luân Đào
4 tháng 4 2019 lúc 18:06

xin lỗi chương trình trước thiếu số 1 nên mình bổ sung:

program sohoanhao;

uses crt;

var i,j,tong: integer;

begin

clrscr;

write('1,');

for i:= 1 to 100 do

begin

tong:=0;

for j:=i-1 downto 1 do

if i mod j = 0 then tong:=tong+j;

if tong = i then write(i,',');

end;

readln

End.

Bình luận (5)
Nguyen
4 tháng 4 2019 lúc 19:24
uses crt;
Var S,i,d:LONGINT;
Begin
clrscr;
For i:=1 to 100 do
Begin
S:=0;
For d:=1 to i do
if i mod d = 0 then
S:=S+d;
if S =2 *i then
write(i:6);
end;
readln;
end.
Bình luận (0)
Lê Văn Đạt
4 tháng 4 2019 lúc 19:59

* To change this license header, choose License Headers in Project Properties.

* To change this template file, choose Tools | Templates

* and open the template in the editor.

*/ package test01;

import java.io.BufferedReader

; import java.io.IOException

; import java.io.InputStreamReader

* @author DOTNETGROUP

*/ public class Test01

* @param args the command line arguments

*/ public static void main(String[] args) throws IOException{

// TODO code application logic here

BufferedReader kbd = new BufferedReader(new InputStreamReader(System.in));

//System.out.print("Nhap a: ");

//String s=kbd.readLine();

//int a=Integer.parseInt(s);

System.out.print("Nhap n: ");

String s=kbd.readLine();

int b=Integer.parseInt(s);

for(int i = 1;i<b;i++)

{ int tong=0; for(int j=1; j<i;j++)

{ if(i%j==0) tong+=j;

if(i==tong)

{ System.out.println(i); } } } }

Bình luận (5)
Natsu Dragneel
4 tháng 4 2019 lúc 21:10

Program So_hoan_hao;

Uses crt;

Var S, i ,j : integer;

Begin
clrscr;

For i:=1 to 100 do

begin

For j:= 1 to i do

if i mod j = 0 then

S:=S+j;

if S = 2*i then

write(i:6);

end;

readln;

end.

Bình luận (0)
Dong tran le
5 tháng 4 2019 lúc 16:24

dùng c++ đc ko ?

Bình luận (0)
Nguyên Nguyễn Phuc
8 tháng 4 2019 lúc 12:12
Số hoàn thiện (hay còn gọi là số hoàn chỉnh, số hoàn hảo) là số nguyên dương có tổng các ước số nguyên dương bé hơn nó bằng chính nó. Số hoàn thiện: 6, 28, 496, 8128,... hien-thi-so-hoan-hao.jpg

/* * To change this license header, choose License Headers in Project Properties. * To change this template file, choose Tools | Templates * and open the template in the editor. */ package test01; import java.io.BufferedReader; import java.io.IOException; import java.io.InputStreamReader; /** * * @author DOTNETGROUP */ public class Test01 { /** * @param args the command line arguments */ public static void main(String[] args) throws IOException{ // TODO code application logic here BufferedReader kbd = new BufferedReader(new InputStreamReader(System.in)); //System.out.print("Nhap a: "); //String s=kbd.readLine(); //int a=Integer.parseInt(s); System.out.print("Nhap n: "); String s=kbd.readLine(); int b=Integer.parseInt(s); for(int i = 1;i<b;i++) { int tong=0; for(int j=1; j<i;j++) { if(i%j==0) tong+=j; } if(i==tong) { System.out.println(i); } } } }

Bình luận (1)
Quỳnh Thư
11 tháng 4 2019 lúc 15:05

program hoc24hoc24;

uses crt;

var i,j,S: integer;

BEGIN

clrscr; S:= 0;

write ('cac so hoan hao nho hon 100 la: ');

for i:= 1 to 100 do

begin

for j:= 1 to i-1 do if i mod j = 0 then S:= S+j;

if i=S then writeln (i);

end;

READLN

END.

Bình luận (1)
Thanh Dat Nguyen
11 tháng 4 2019 lúc 17:55

1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,31,32,33,34,35,36,37,38,39,40,41,42,43,44,45,46,47,48,49,50,
51,52,53,54,55,56,57,58,59,60,61,62,63,64,65,66,67,68,69,70,71,72,73,
74,75,76,77,78,79,80,81,82,83,84,85,86,87,88,89,90,91,92,93,94,95,96,
97,98,99,100
xong từ 1 đến 100 như yêu cầu

Bình luận (3)
Phạm Văn Đức
21 tháng 4 2019 lúc 15:55

Program viet_chuong_trinh_tinh_tong;
Uses Crt;
Var i,s:integer;
Begin
Clrscr;
i:=2;
While (i>1) and (i<=100) do
Begin
s:=s+i;
i:=i+2;
End;
Writeln(S);
Readln;
End.

Bình luận (0)

Các câu hỏi tương tự
duy lê
Xem chi tiết
Thảo Nguyên 36-88
Xem chi tiết
Hưng Quốc
Xem chi tiết
Ma Phan Đức
Xem chi tiết
lio Nana
Xem chi tiết
đức minh
Xem chi tiết
nguyễn vũ thành công
Xem chi tiết
Eriken
Xem chi tiết
Nhân lê
Xem chi tiết