Một giải pháp Naive sẽ là lặp lại tất cả các số từ 1 đến n, kiểm tra xem số đó có chia hết n không và in nó. Dưới đây là một chương trình cho cùng
C++
// C++ implementation of Naive method to print all
// divisors
#include
using
namespace
std;
The divisors of 100 are: 1 2 4 5 10 20 25 50 1000
The divisors of 100 are: 1 2 4 5 10 20 25 50 1001
The divisors of 100 are: 1 2 4 5 10 20 25 50 1002
The divisors of 100 are: 1 2 4 5 10 20 25 50 1003
The divisors of 100 are: 1 2 4 5 10 20 25 50 1004
The divisors of 100 are: 1 2 4 5 10 20 25 50 1005
The divisors of 100 are: 1 2 4 5 10 20 25 50 1006_______0_______7
The divisors of 100 are: 1 2 4 5 10 20 25 50 1008
The divisors of 100 are: 1 2 4 5 10 20 25 50 1003
The divisors of 100 are: 1 100 2 50 4 25 5 20 100
The divisors of 100 are: 1 100 2 50 4 25 5 20 101
The divisors of 100 are: 1 100 2 50 4 25 5 20 102
The divisors of 100 are: 1 100 2 50 4 25 5 20 103
The divisors of 100 are: 1 100 2 50 4 25 5 20 104
The divisors of 100 are: 1 100 2 50 4 25 5 20 105
The divisors of 100 are: 1 100 2 50 4 25 5 20 106
The divisors of 100 are: 1 100 2 50 4 25 5 20 107
The divisors of 100 are: 1 100 2 50 4 25 5 20 108
// C++ implementation of Naive method to print all
0
The divisors of 100 are: 1 2 4 5 10 20 25 50 1003
// C++ implementation of Naive method to print all
2The divisors of 100 are: 1 2 4 5 10 20 25 50 1005
The divisors of 100 are: 1 2 4 5 10 20 25 50 1006_______10_______5
// C++ implementation of Naive method to print all
6// C++ implementation of Naive method to print all
7The divisors of 100 are: 1 2 4 5 10 20 25 50 1006
// C++ implementation of Naive method to print all
9The divisors of 100 are: 1 2 4 5 10 20 25 50 1006_______538_______1
// divisors
2The divisors of 100 are: 1 100 2 50 4 25 5 20 108
// divisors
5
C
// divisors
6
// divisors
// divisors
8
The divisors of 100 are: 1 2 4 5 10 20 25 50 1000
The divisors of 100 are: 1 2 4 5 10 20 25 50 1001
The divisors of 100 are: 1 2 4 5 10 20 25 50 1002
The divisors of 100 are: 1 2 4 5 10 20 25 50 1003
The divisors of 100 are: 1 2 4 5 10 20 25 50 1004
The divisors of 100 are: 1 2 4 5 10 20 25 50 1005
The divisors of 100 are: 1 2 4 5 10 20 25 50 1006_______0_______7
The divisors of 100 are: 1 2 4 5 10 20 25 50 1008
The divisors of 100 are: 1 2 4 5 10 20 25 50 1003
using
0The divisors of 100 are: 1 100 2 50 4 25 5 20 101
The divisors of 100 are: 1 100 2 50 4 25 5 20 102
using
3The divisors of 100 are: 1 100 2 50 4 25 5 20 104
using
5The divisors of 100 are: 1 2 4 5 10 20 25 50 1008
using
7using
8The divisors of 100 are: 1 100 2 50 4 25 5 20 108
// C++ implementation of Naive method to print all
0
The divisors of 100 are: 1 2 4 5 10 20 25 50 1003
// C++ implementation of Naive method to print all
2The divisors of 100 are: 1 2 4 5 10 20 25 50 1005
The divisors of 100 are: 1 2 4 5 10 20 25 50 1006_______540_______5
The divisors of 100 are: 1 2 4 5 10 20 25 50 1008
// C++ implementation of Naive method to print all
6namespace
9The divisors of 100 are: 1 2 4 5 10 20 25 50 1006
// C++ implementation of Naive method to print all
9The divisors of 100 are: 1 2 4 5 10 20 25 50 1006_______538_______1
// divisors
2The divisors of 100 are: 1 100 2 50 4 25 5 20 108
Java
std;
6
// divisors
std;
9
0
The divisors of 100 are: 1 2 4 5 10 20 25 50 1005
The divisors of 100 are: 1 2 4 5 10 20 25 50 1006
3The divisors of 100 are: 1 2 4 5 10 20 25 50 1006_______543_______5
The divisors of 100 are: 1 2 4 5 10 20 25 50 1001
The divisors of 100 are: 1 2 4 5 10 20 25 50 1002
The divisors of 100 are: 1 2 4 5 10 20 25 50 1003
The divisors of 100 are: 1 2 4 5 10 20 25 50 1004
The divisors of 100 are: 1 2 4 5 10 20 25 50 1006_______0_______5
The divisors of 100 are: 1 100 2 50 4 25 5 20 101
The divisors of 100 are: 1 2 4 5 10 20 25 50 1007
The divisors of 100 are: 1 2 4 5 10 20 25 50 1008_______0_______3
The divisors of 100 are: 1 2 4 5 10 20 25 50 10006
The divisors of 100 are: 1 2 4 5 10 20 25 50 10007
The divisors of 100 are: 1 2 4 5 10 20 25 50 10008
The divisors of 100 are: 1 100 2 50 4 25 5 20 104
The divisors of 100 are: 1 100 2 50 4 25 5 20 102
The divisors of 100 are: 1 2 4 5 10 20 25 50 10011
The divisors of 100 are: 1 2 4 5 10 20 25 50 10012
The divisors of 100 are: 1 2 4 5 10 20 25 50 10013
The divisors of 100 are: 1 2 4 5 10 20 25 50 10014
The divisors of 100 are: 1 2 4 5 10 20 25 50 10015
The divisors of 100 are: 1 100 2 50 4 25 5 20 106
namespace
9The divisors of 100 are: 1 2 4 5 10 20 25 50 1006
The divisors of 100 are: 1 100 2 50 4 25 5 20 108
The divisors of 100 are: 1 2 4 5 10 20 25 50 1006
The divisors of 100 are: 1 2 4 5 10 20 25 50 10022
The divisors of 100 are: 1 2 4 5 10 20 25 50 1006_______0_______24
5 The divisors of 100 are: 1 2 4 5 10 20 25 50 1001
The divisors of 100 are: 1 2 4 5 10 20 25 50 10027
The divisors of 100 are: 1 2 4 5 10 20 25 50 1006_______0_______5
The divisors of 100 are: 1 100 2 50 4 25 5 20 101
The divisors of 100 are: 1 2 4 5 10 20 25 50 10031
The divisors of 100 are: 1 2 4 5 10 20 25 50 10032
namespace
9The divisors of 100 are: 1 100 2 50 4 25 5 20 101
The divisors of 100 are: 1 2 4 5 10 20 25 50 1002
The divisors of 100 are: 1 2 4 5 10 20 25 50 10036
The divisors of 100 are: 1 2 4 5 10 20 25 50 10037
The divisors of 100 are: 1 2 4 5 10 20 25 50 1006
The divisors of 100 are: 1 100 2 50 4 25 5 20 108
The divisors of 100 are: 1 100 2 50 4 25 5 20 108
Python3
The divisors of 100 are: 1 2 4 5 10 20 25 50 10041
The divisors of 100 are: 1 2 4 5 10 20 25 50 10042
The divisors of 100 are: 1 2 4 5 10 20 25 50 10044
The divisors of 100 are: 1 2 4 5 10 20 25 50 10045
The divisors of 100 are: 1 2 4 5 10 20 25 50 10046
The divisors of 100 are: 1 2 4 5 10 20 25 50 1006_______0_______48
The divisors of 100 are: 1 2 4 5 10 20 25 50 10049
The divisors of 100 are: 1 2 4 5 10 20 25 50 10007
The divisors of 100 are: 1 2 4 5 10 20 25 50 1006_______0_______52
The divisors of 100 are: 1 2 4 5 10 20 25 50 10053
The divisors of 100 are: 1 2 4 5 10 20 25 50 10049
The divisors of 100 are: 1 2 4 5 10 20 25 50 10055
The divisors of 100 are: 1 100 2 50 4 25 5 20 101
The divisors of 100 are: 1 100 2 50 4 25 5 20 102
The divisors of 100 are: 1 2 4 5 10 20 25 50 10058_______0_______59
The divisors of 100 are: 1 2 4 5 10 20 25 50 10048
The divisors of 100 are: 1 2 4 5 10 20 25 50 10049
The divisors of 100 are: 1 2 4 5 10 20 25 50 10049
The divisors of 100 are: 1 2 4 5 10 20 25 50 10012
The divisors of 100 are: 1 2 4 5 10 20 25 50 10064
The divisors of 100 are: 1 100 2 50 4 25 5 20 104
The divisors of 100 are: 1 2 4 5 10 20 25 50 10066
The divisors of 100 are: 1 2 4 5 10 20 25 50 10067_______0_______49
The divisors of 100 are: 1 100 2 50 4 25 5 20 106
The divisors of 100 are: 1 2 4 5 10 20 25 50 10013
The divisors of 100 are: 1 100 2 50 4 25 5 20 101
The divisors of 100 are: 1 2 4 5 10 20 25 50 10048_______0_______49
The divisors of 100 are: 1 2 4 5 10 20 25 50 10048
The divisors of 100 are: 1 2 4 5 10 20 25 50 10075
The divisors of 100 are: 1 2 4 5 10 20 25 50 10007
The divisors of 100 are: 1 2 4 5 10 20 25 50 10077
The divisors of 100 are: 1 2 4 5 10 20 25 50 10078
The divisors of 100 are: 1 2 4 5 10 20 25 50 10066
The divisors of 100 are: 1 2 4 5 10 20 25 50 1008
The divisors of 100 are: 1 2 4 5 10 20 25 50 10032
The divisors of 100 are: 1 2 4 5 10 20 25 50 10013
The divisors of 100 are: 1 2 4 5 10 20 25 50 1002
The divisors of 100 are: 1 2 4 5 10 20 25 50 10036
The divisors of 100 are: 1 2 4 5 10 20 25 50 10013
The divisors of 100 are: 1 2 4 5 10 20 25 50 10087
C#
The divisors of 100 are: 1 2 4 5 10 20 25 50 10088
The divisors of 100 are: 1 2 4 5 10 20 25 50 10089
using
The divisors of 100 are: 1 2 4 5 10 20 25 50 10091
std;
9
The divisors of 100 are: 1 2 4 5 10 20 25 50 10094
The divisors of 100 are: 1 2 4 5 10 20 25 50 10095
The divisors of 100 are: 1 2 4 5 10 20 25 50 1006
3The divisors of 100 are: 1 2 4 5 10 20 25 50 1006_______543_______5
The divisors of 100 are: 1 2 4 5 10 20 25 50 1001
The divisors of 100 are: 1 2 4 5 10 20 25 50 1002
The divisors of 100 are: 1 2 4 5 10 20 25 50 1003
The divisors of 100 are: 1 2 4 5 10 20 25 50 1004
The divisors of 100 are: 1 2 4 5 10 20 25 50 1006_______0_______5
The divisors of 100 are: 1 100 2 50 4 25 5 20 101
The divisors of 100 are: 1 2 4 5 10 20 25 50 1007
The divisors of 100 are: 1 2 4 5 10 20 25 50 1008
The divisors of 100 are: 1 2 4 5 10 20 25 50 1003
The divisors of 100 are: 1 100 2 50 4 25 5 20 100
The divisors of 100 are: 1 100 2 50 4 25 5 20 104
The divisors of 100 are: 1 100 2 50 4 25 5 20 102
The divisors of 100 are: 1 100 2 50 4 25 5 20 103
The divisors of 100 are: 1 2 4 5 10 20 25 50 10014
The divisors of 100 are: 1 100 2 50 4 25 5 20 1015
The divisors of 100 are: 1 100 2 50 4 25 5 20 106
namespace
9The divisors of 100 are: 1 2 4 5 10 20 25 50 1006
The divisors of 100 are: 1 100 2 50 4 25 5 20 108
The divisors of 100 are: 1 2 4 5 10 20 25 50 1006
The divisors of 100 are: 1 2 4 5 10 20 25 50 10022
The divisors of 100 are: 1 2 4 5 10 20 25 50 1006_______0_______24
5 The divisors of 100 are: 1 2 4 5 10 20 25 50 1001
The divisors of 100 are: 1 100 2 50 4 25 5 20 1027
The divisors of 100 are: 1 2 4 5 10 20 25 50 1006_______0_______5
The divisors of 100 are: 1 100 2 50 4 25 5 20 101
The divisors of 100 are: 1 100 2 50 4 25 5 20 1031
The divisors of 100 are: 1 100 2 50 4 25 5 20 1032
The divisors of 100 are: 1 100 2 50 4 25 5 20 1033
The divisors of 100 are: 1 100 2 50 4 25 5 20 1034
The divisors of 100 are: 1 100 2 50 4 25 5 20 1035
namespace
9The divisors of 100 are: 1 100 2 50 4 25 5 20 101
The divisors of 100 are: 1 100 2 50 4 25 5 20 1038
The divisors of 100 are: 1 2 4 5 10 20 25 50 1006
The divisors of 100 are: 1 100 2 50 4 25 5 20 108
The divisors of 100 are: 1 100 2 50 4 25 5 20 108
The divisors of 100 are: 1 100 2 50 4 25 5 20 1043
PHP
The divisors of 100 are: 1 100 2 50 4 25 5 20 1044
The divisors of 100 are: 1 100 2 50 4 25 5 20 1045
The divisors of 100 are: 1 100 2 50 4 25 5 20 1046
The divisors of 100 are: 1 2 4 5 10 20 25 50 1000
The divisors of 100 are: 1 100 2 50 4 25 5 20 1049
The divisors of 100 are: 1 2 4 5 10 20 25 50 1002_______10_______51
The divisors of 100 are: 1 2 4 5 10 20 25 50 10013
The divisors of 100 are: 1 2 4 5 10 20 25 50 1005
The divisors of 100 are: 1 2 4 5 10 20 25 50 1006_______0_______7
The divisors of 100 are: 1 2 4 5 10 20 25 50 1008
The divisors of 100 are: 1 100 2 50 4 25 5 20 1057
The divisors of 100 are: 1 100 2 50 4 25 5 20 1058
The divisors of 100 are: 1 100 2 50 4 25 5 20 1057
The divisors of 100 are: 1 100 2 50 4 25 5 20 1060
The divisors of 100 are: 1 100 2 50 4 25 5 20 1051
// C++ implementation of Naive method to print all
7The divisors of 100 are: 1 100 2 50 4 25 5 20 1057
The divisors of 100 are: 1 100 2 50 4 25 5 20 1064
The divisors of 100 are: 1 100 2 50 4 25 5 20 101
The divisors of 100 are: 1 100 2 50 4 25 5 20 102
The divisors of 100 are: 1 2 4 5 10 20 25 50 1008
The divisors of 100 are: 1 100 2 50 4 25 5 20 1051
The divisors of 100 are: 1 2 4 5 10 20 25 50 10059
The divisors of 100 are: 1 100 2 50 4 25 5 20 1057
The divisors of 100 are: 1 100 2 50 4 25 5 20 1071
The divisors of 100 are: 1 100 2 50 4 25 5 20 104
The divisors of 100 are: 1 100 2 50 4 25 5 20 1073
The divisors of 100 are: 1 100 2 50 4 25 5 20 1057
The divisors of 100 are: 1 100 2 50 4 25 5 20 1033
The divisors of 100 are: 1 100 2 50 4 25 5 20 106
// C++ implementation of Naive method to print all
7The divisors of 100 are: 1 100 2 50 4 25 5 20 108
The divisors of 100 are: 1 100 2 50 4 25 5 20 1080
The divisors of 100 are: 1 100 2 50 4 25 5 20 1073
The divisors of 100 are: 1 100 2 50 4 25 5 20 1082
// C++ implementation of Naive method to print all
7// C++ implementation of Naive method to print all
9
The divisors of 100 are: 1 100 2 50 4 25 5 20 1086
The divisors of 100 are: 1 100 2 50 4 25 5 20 1087
Javascript
The divisors of 100 are: 1 100 2 50 4 25 5 20 1088
The divisors of 100 are: 1 100 2 50 4 25 5 20 1090
The divisors of 100 are: 1 100 2 50 4 25 5 20 1091
The divisors of 100 are: 1 100 2 50 4 25 5 20 1093
The divisors of 100 are: 1 100 2 50 4 25 5 20 1049
The divisors of 100 are: 1 100 2 50 4 25 5 20 1095
The divisors of 100 are: 1 100 2 50 4 25 5 20 1096
The divisors of 100 are: 1 2 4 5 10 20 25 50 1006_______0_______7
The divisors of 100 are: 1 100 2 50 4 25 5 20 1099
The divisors of 100 are: 1 100 2 50 4 25 5 20 101
The divisors of 100 are: 1 100 2 50 4 25 5 20 102
// C++ implementation of Naive method to print all
02The divisors of 100 are: 1 100 2 50 4 25 5 20 104
// C++ implementation of Naive method to print all
04The divisors of 100 are: 1 100 2 50 4 25 5 20 106
// C++ implementation of Naive method to print all
06// C++ implementation of Naive method to print all
07
// C++ implementation of Naive method to print all
0
The divisors of 100 are: 1 2 4 5 10 20 25 50 1006_______537_______12
// C++ implementation of Naive method to print all
13 The divisors of 100 are: 1 2 4 5 10 20 25 50 10075
// C++ implementation of Naive method to print all
15// C++ implementation of Naive method to print all
06The divisors of 100 are: 1 2 4 5 10 20 25 50 1006
// C++ implementation of Naive method to print all
9The divisors of 100 are: 1 2 4 5 10 20 25 50 10095
// C++ implementation of Naive method to print all
20
The divisors of 100 are: 1 2 4 5 10 20 25 50 10095
// C++ implementation of Naive method to print all
22
đầu ra
The divisors of 100 are: 1 2 4 5 10 20 25 50 100
Thời gian phức tạp. TRÊN]
Không gian phụ trợ. Ô[1]
Chúng ta có thể cải thiện giải pháp trên không?
Nếu chúng ta xem xét cẩn thận, tất cả các ước số đều có mặt theo cặp. Ví dụ: nếu n = 100, thì các cặp ước khác nhau là. [1,100], [2,50], [4,25], [5,20], [10,10]
Sử dụng thực tế này, chúng tôi có thể tăng tốc đáng kể chương trình của mình.
Tuy nhiên, chúng ta phải cẩn thận nếu có hai ước bằng nhau như trong trường hợp [10, 10]. Trong trường hợp như vậy, chúng tôi chỉ in một trong số chúng.
Dưới đây là một triển khai cho cùng
C++
// C++ implementation of Naive method to print all
23
#include
// C++ implementation of Naive method to print all
25
using
namespace
std;
// C++ implementation of Naive method to print all
30
The divisors of 100 are: 1 2 4 5 10 20 25 50 1001
The divisors of 100 are: 1 2 4 5 10 20 25 50 1002
The divisors of 100 are: 1 2 4 5 10 20 25 50 1003
The divisors of 100 are: 1 2 4 5 10 20 25 50 1004
The divisors of 100 are: 1 2 4 5 10 20 25 50 1005
The divisors of 100 are: 1 2 4 5 10 20 25 50 1006
// C++ implementation of Naive method to print all
37The divisors of 100 are: 1 2 4 5 10 20 25 50 1006_______0_______7
The divisors of 100 are: 1 2 4 5 10 20 25 50 1008
The divisors of 100 are: 1 2 4 5 10 20 25 50 1003
// C++ implementation of Naive method to print all
42// C++ implementation of Naive method to print all
43// C++ implementation of Naive method to print all
44The divisors of 100 are: 1 2 4 5 10 20 25 50 1006_______0_______5
The divisors of 100 are: 1 100 2 50 4 25 5 20 101
The divisors of 100 are: 1 100 2 50 4 25 5 20 102
// C++ implementation of Naive method to print all
49The divisors of 100 are: 1 100 2 50 4 25 5 20 101
The divisors of 100 are: 1 2 4 5 10 20 25 50 1005
The divisors of 100 are: 1 100 2 50 4 25 5 20 104
// C++ implementation of Naive method to print all
53The divisors of 100 are: 1 100 2 50 4 25 5 20 104
The divisors of 100 are: 1 100 2 50 4 25 5 20 102
// C++ implementation of Naive method to print all
56The divisors of 100 are: 1 2 4 5 10 20 25 50 10014
The divisors of 100 are: 1 100 2 50 4 25 5 20 105
The divisors of 100 are: 1 100 2 50 4 25 5 20 106
The divisors of 100 are: 1 100 2 50 4 25 5 20 107
The divisors of 100 are: 1 100 2 50 4 25 5 20 104
// C++ implementation of Naive method to print all
63 // C++ implementation of Naive method to print all
64The divisors of 100 are: 1 2 4 5 10 20 25 50 10014
The divisors of 100 are: 1 100 2 50 4 25 5 20 105
The divisors of 100 are: 1 100 2 50 4 25 5 20 106
// C++ implementation of Naive method to print all
68The divisors of 100 are: 1 100 2 50 4 25 5 20 106
// C++ implementation of Naive method to print all
70The divisors of 100 are: 1 100 2 50 4 25 5 20 101
The divisors of 100 are: 1 100 2 50 4 25 5 20 108
The divisors of 100 are: 1 2 4 5 10 20 25 50 1006
The divisors of 100 are: 1 100 2 50 4 25 5 20 108
The divisors of 100 are: 1 100 2 50 4 25 5 20 108
// C++ implementation of Naive method to print all
0
The divisors of 100 are: 1 2 4 5 10 20 25 50 1003
// C++ implementation of Naive method to print all
2The divisors of 100 are: 1 2 4 5 10 20 25 50 1005
The divisors of 100 are: 1 2 4 5 10 20 25 50 1006_______10_______5
// C++ implementation of Naive method to print all
6// C++ implementation of Naive method to print all
7The divisors of 100 are: 1 2 4 5 10 20 25 50 1006
// C++ implementation of Naive method to print all
9The divisors of 100 are: 1 2 4 5 10 20 25 50 1006_______538_______1
// divisors
2The divisors of 100 are: 1 100 2 50 4 25 5 20 108
// divisors
5
C
// C++ implementation of Naive method to print all
23
// C++ implementation of Naive method to print all
94
// C++ implementation of Naive method to print all
25
// C++ implementation of Naive method to print all
30
The divisors of 100 are: 1 2 4 5 10 20 25 50 1001
The divisors of 100 are: 1 2 4 5 10 20 25 50 1002
The divisors of 100 are: 1 2 4 5 10 20 25 50 1003
The divisors of 100 are: 1 2 4 5 10 20 25 50 1004
The divisors of 100 are: 1 2 4 5 10 20 25 50 1005
The divisors of 100 are: 1 2 4 5 10 20 25 50 1006
// C++ implementation of Naive method to print all
37The divisors of 100 are: 1 2 4 5 10 20 25 50 1006_______0_______7
The divisors of 100 are: 1 2 4 5 10 20 25 50 1008
The divisors of 100 are: 1 2 4 5 10 20 25 50 1003
// C++ implementation of Naive method to print all
42// C++ implementation of Naive method to print all
43// C++ implementation of Naive method to print all
44The divisors of 100 are: 1 2 4 5 10 20 25 50 1006_______0_______5
The divisors of 100 are: 1 100 2 50 4 25 5 20 101
The divisors of 100 are: 1 100 2 50 4 25 5 20 102
// C++ implementation of Naive method to print all
49The divisors of 100 are: 1 100 2 50 4 25 5 20 101
The divisors of 100 are: 1 2 4 5 10 20 25 50 1005
The divisors of 100 are: 1 100 2 50 4 25 5 20 104
// C++ implementation of Naive method to print all
53The divisors of 100 are: 1 100 2 50 4 25 5 20 104
The divisors of 100 are: 1 100 2 50 4 25 5 20 102
// C++ implementation of Naive method to print all
56The divisors of 100 are: 1 2 4 5 10 20 25 50 10014
using
5The divisors of 100 are: 1 2 4 5 10 20 25 50 1008
using
7// divisors
28
The divisors of 100 are: 1 100 2 50 4 25 5 20 104
// C++ implementation of Naive method to print all
63 // C++ implementation of Naive method to print all
64The divisors of 100 are: 1 2 4 5 10 20 25 50 10014
using
5The divisors of 100 are: 1 2 4 5 10 20 25 50 1008
// divisors
36// divisors
37The divisors of 100 are: 1 100 2 50 4 25 5 20 101
The divisors of 100 are: 1 100 2 50 4 25 5 20 108
The divisors of 100 are: 1 2 4 5 10 20 25 50 1006
The divisors of 100 are: 1 100 2 50 4 25 5 20 108
The divisors of 100 are: 1 100 2 50 4 25 5 20 108
// C++ implementation of Naive method to print all
0
The divisors of 100 are: 1 2 4 5 10 20 25 50 1003
// C++ implementation of Naive method to print all
2The divisors of 100 are: 1 2 4 5 10 20 25 50 1005
The divisors of 100 are: 1 2 4 5 10 20 25 50 1006_______540_______5
The divisors of 100 are: 1 2 4 5 10 20 25 50 1008
// C++ implementation of Naive method to print all
6namespace
9The divisors of 100 are: 1 2 4 5 10 20 25 50 1006
// C++ implementation of Naive method to print all
9The divisors of 100 are: 1 2 4 5 10 20 25 50 1006_______538_______1
// divisors
2The divisors of 100 are: 1 100 2 50 4 25 5 20 108
Java
// C++ implementation of Naive method to print all
23
std;
9
0
The divisors of 100 are: 1 2 4 5 10 20 25 50 1005
The divisors of 100 are: 1 2 4 5 10 20 25 50 1006
3The divisors of 100 are: 1 2 4 5 10 20 25 50 1006_______543_______5
The divisors of 100 are: 1 2 4 5 10 20 25 50 1001
The divisors of 100 are: 1 2 4 5 10 20 25 50 1002
The divisors of 100 are: 1 2 4 5 10 20 25 50 1003
The divisors of 100 are: 1 2 4 5 10 20 25 50 1004
The divisors of 100 are: 1 2 4 5 10 20 25 50 1006_______0_______5
The divisors of 100 are: 1 100 2 50 4 25 5 20 101____537_______37
The divisors of 100 are: 1 100 2 50 4 25 5 20 101
The divisors of 100 are: 1 2 4 5 10 20 25 50 1007
The divisors of 100 are: 1 2 4 5 10 20 25 50 1008_______0_______3
The divisors of 100 are: 1 2 4 5 10 20 25 50 10006
The divisors of 100 are: 1 2 4 5 10 20 25 50 10007
// divisors
82The divisors of 100 are: 1 100 2 50 4 25 5 20 101
The divisors of 100 are: 1 2 4 5 10 20 25 50 1005
The divisors of 100 are: 1 100 2 50 4 25 5 20 104
The divisors of 100 are: 1 100 2 50 4 25 5 20 102
The divisors of 100 are: 1 2 4 5 10 20 25 50 10011
The divisors of 100 are: 1 2 4 5 10 20 25 50 10012
The divisors of 100 are: 1 2 4 5 10 20 25 50 10013
The divisors of 100 are: 1 100 2 50 4 25 5 20 104
The divisors of 100 are: 1 2 4 5 10 20 25 50 1005
The divisors of 100 are: 1 2 4 5 10 20 25 50 10014
// C++ implementation of Naive method to print all
53The divisors of 100 are: 1 2 4 5 10 20 25 50 10014
The divisors of 100 are: 1 100 2 50 4 25 5 20 102
// C++ implementation of Naive method to print all
56// divisors
97____538_______98
The divisors of 100 are: 1 100 2 50 4 25 5 20 106
#include
00#include
01
The divisors of 100 are: 1 2 4 5 10 20 25 50 10014
// C++ implementation of Naive method to print all
63 // C++ implementation of Naive method to print all
64// divisors
97
The divisors of 100 are: 1 2 4 5 10 20 25 50 10015
The divisors of 100 are: 1 100 2 50 4 25 5 20 106
#include
08The divisors of 100 are: 1 100 2 50 4 25 5 20 106
namespace
9The divisors of 100 are: 1 100 2 50 4 25 5 20 104
The divisors of 100 are: 1 100 2 50 4 25 5 20 108
The divisors of 100 are: 1 100 2 50 4 25 5 20 101
The divisors of 100 are: 1 100 2 50 4 25 5 20 108
The divisors of 100 are: 1 2 4 5 10 20 25 50 1006
The divisors of 100 are: 1 100 2 50 4 25 5 20 108
The divisors of 100 are: 1 2 4 5 10 20 25 50 1006
The divisors of 100 are: 1 2 4 5 10 20 25 50 10022
The divisors of 100 are: 1 2 4 5 10 20 25 50 1006_______0_______24
5 The divisors of 100 are: 1 2 4 5 10 20 25 50 1001
The divisors of 100 are: 1 2 4 5 10 20 25 50 10027
The divisors of 100 are: 1 2 4 5 10 20 25 50 1006_______0_______5
The divisors of 100 are: 1 100 2 50 4 25 5 20 101
The divisors of 100 are: 1 2 4 5 10 20 25 50 10031
The divisors of 100 are: 1 2 4 5 10 20 25 50 10032
namespace
9The divisors of 100 are: 1 100 2 50 4 25 5 20 101
The divisors of 100 are: 1 2 4 5 10 20 25 50 1002
The divisors of 100 are: 1 2 4 5 10 20 25 50 10036
The divisors of 100 are: 1 2 4 5 10 20 25 50 10037
The divisors of 100 are: 1 2 4 5 10 20 25 50 1006
The divisors of 100 are: 1 100 2 50 4 25 5 20 108
The divisors of 100 are: 1 100 2 50 4 25 5 20 108
Python3
#include
38
#include
39 #include
40
The divisors of 100 are: 1 2 4 5 10 20 25 50 10044
The divisors of 100 are: 1 2 4 5 10 20 25 50 10045
The divisors of 100 are: 1 2 4 5 10 20 25 50 10046
The divisors of 100 are: 1 2 4 5 10 20 25 50 10095
The divisors of 100 are: 1 2 4 5 10 20 25 50 1006
#include
47The divisors of 100 are: 1 2 4 5 10 20 25 50 1006_______0_______48
The divisors of 100 are: 1 2 4 5 10 20 25 50 10049
The divisors of 100 are: 1 2 4 5 10 20 25 50 10007
The divisors of 100 are: 1 2 4 5 10 20 25 50 1006_______0_______52
The divisors of 100 are: 1 2 4 5 10 20 25 50 10053
The divisors of 100 are: 1 2 4 5 10 20 25 50 10049
#include
56The divisors of 100 are: 1 2 4 5 10 20 25 50 10077
The divisors of 100 are: 1 100 2 50 4 25 5 20 101
The divisors of 100 are: 1 100 2 50 4 25 5 20 102
The divisors of 100 are: 1 2 4 5 10 20 25 50 10058_______0_______59
The divisors of 100 are: 1 2 4 5 10 20 25 50 10048
The divisors of 100 are: 1 2 4 5 10 20 25 50 10049
The divisors of 100 are: 1 2 4 5 10 20 25 50 10049
The divisors of 100 are: 1 2 4 5 10 20 25 50 10012
The divisors of 100 are: 1 2 4 5 10 20 25 50 10064
#include
67
The divisors of 100 are: 1 100 2 50 4 25 5 20 104
#include
69The divisors of 100 are: 1 100 2 50 4 25 5 20 104
The divisors of 100 are: 1 100 2 50 4 25 5 20 102
The divisors of 100 are: 1 2 4 5 10 20 25 50 10058_______539_______73
The divisors of 100 are: 1 2 4 5 10 20 25 50 10048
The divisors of 100 are: 1 2 4 5 10 20 25 50 10049
The divisors of 100 are: 1 2 4 5 10 20 25 50 10049
#include
77The divisors of 100 are: 1 2 4 5 10 20 25 50 10014
The divisors of 100 are: 1 2 4 5 10 20 25 50 10066
The divisors of 100 are: 1 2 4 5 10 20 25 50 10067
The divisors of 100 are: 1 2 4 5 10 20 25 50 10049
The divisors of 100 are: 1 100 2 50 4 25 5 20 106
The divisors of 100 are: 1 2 4 5 10 20 25 50 10013
The divisors of 100 are: 1 100 2 50 4 25 5 20 104
// C++ implementation of Naive method to print all
63 #include
86The divisors of 100 are: 1 2 4 5 10 20 25 50 10014____539_______88
The divisors of 100 are: 1 2 4 5 10 20 25 50 10014
The divisors of 100 are: 1 2 4 5 10 20 25 50 10066
#include
91The divisors of 100 are: 1 2 4 5 10 20 25 50 1003
The divisors of 100 are: 1 2 4 5 10 20 25 50 10058
#include
73#include
95The divisors of 100 are: 1 2 4 5 10 20 25 50 10049
The divisors of 100 are: 1 100 2 50 4 25 5 20 106
The divisors of 100 are: 1 2 4 5 10 20 25 50 10013
The divisors of 100 are: 1 100 2 50 4 25 5 20 101
The divisors of 100 are: 1 2 4 5 10 20 25 50 10048_______0_______49
The divisors of 100 are: 1 2 4 5 10 20 25 50 10048
The divisors of 100 are: 1 2 4 5 10 20 25 50 10075
The divisors of 100 are: 1 2 4 5 10 20 25 50 10007
The divisors of 100 are: 1 2 4 5 10 20 25 50 10078
The divisors of 100 are: 1 2 4 5 10 20 25 50 10066
The divisors of 100 are: 1 2 4 5 10 20 25 50 1008
The divisors of 100 are: 1 2 4 5 10 20 25 50 10032
The divisors of 100 are: 1 2 4 5 10 20 25 50 10013
The divisors of 100 are: 1 2 4 5 10 20 25 50 1002
The divisors of 100 are: 1 2 4 5 10 20 25 50 10036
The divisors of 100 are: 1 2 4 5 10 20 25 50 10013
The divisors of 100 are: 1 2 4 5 10 20 25 50 10087
C#
using
16
using
17
using
The divisors of 100 are: 1 2 4 5 10 20 25 50 10091
std;
9
The divisors of 100 are: 1 2 4 5 10 20 25 50 10094
The divisors of 100 are: 1 2 4 5 10 20 25 50 10095
The divisors of 100 are: 1 2 4 5 10 20 25 50 1006
3The divisors of 100 are: 1 2 4 5 10 20 25 50 1006_______543_______5
The divisors of 100 are: 1 2 4 5 10 20 25 50 1001
The divisors of 100 are: 1 2 4 5 10 20 25 50 1002
The divisors of 100 are: 1 2 4 5 10 20 25 50 1003
The divisors of 100 are: 1 2 4 5 10 20 25 50 1004
The divisors of 100 are: 1 2 4 5 10 20 25 50 1006_______0_______5
The divisors of 100 are: 1 2 4 5 10 20 25 50 10077
The divisors of 100 are: 1 100 2 50 4 25 5 20 101
using
36The divisors of 100 are: 1 100 2 50 4 25 5 20 101____540_______38
The divisors of 100 are: 1 100 2 50 4 25 5 20 101
The divisors of 100 are: 1 2 4 5 10 20 25 50 1007
The divisors of 100 are: 1 2 4 5 10 20 25 50 1008
The divisors of 100 are: 1 2 4 5 10 20 25 50 1003
using
43using
44____540_______45
The divisors of 100 are: 1 100 2 50 4 25 5 20 101
The divisors of 100 are: 1 2 4 5 10 20 25 50 1005
The divisors of 100 are: 1 100 2 50 4 25 5 20 104
The divisors of 100 are: 1 100 2 50 4 25 5 20 102
The divisors of 100 are: 1 100 2 50 4 25 5 20 103
The divisors of 100 are: 1 100 2 50 4 25 5 20 104
The divisors of 100 are: 1 2 4 5 10 20 25 50 1005
using
53
The divisors of 100 are: 1 2 4 5 10 20 25 50 10014
using
55The divisors of 100 are: 1 2 4 5 10 20 25 50 10014
using
57The divisors of 100 are: 1 2 4 5 10 20 25 50 10014
The divisors of 100 are: 1 100 2 50 4 25 5 20 102
using
60// divisors
97____540_______62
The divisors of 100 are: 1 100 2 50 4 25 5 20 106
namespace
9using
53
The divisors of 100 are: 1 2 4 5 10 20 25 50 10014
// C++ implementation of Naive method to print all
64The divisors of 100 are: 1 2 4 5 10 20 25 50 10014____537_______63
// divisors
97____540_______62
The divisors of 100 are: 1 100 2 50 4 25 5 20 106
using
73_______540_______74
The divisors of 100 are: 1 100 2 50 4 25 5 20 106
namespace
9The divisors of 100 are: 1 100 2 50 4 25 5 20 104
The divisors of 100 are: 1 100 2 50 4 25 5 20 108
The divisors of 100 are: 1 100 2 50 4 25 5 20 101
The divisors of 100 are: 1 100 2 50 4 25 5 20 108
The divisors of 100 are: 1 2 4 5 10 20 25 50 1006
The divisors of 100 are: 1 100 2 50 4 25 5 20 108
The divisors of 100 are: 1 2 4 5 10 20 25 50 1006
The divisors of 100 are: 1 2 4 5 10 20 25 50 10022
The divisors of 100 are: 1 2 4 5 10 20 25 50 1006_______0_______24
5 The divisors of 100 are: 1 2 4 5 10 20 25 50 1001
The divisors of 100 are: 1 100 2 50 4 25 5 20 1027
The divisors of 100 are: 1 2 4 5 10 20 25 50 1006_______0_______5
The divisors of 100 are: 1 100 2 50 4 25 5 20 101
The divisors of 100 are: 1 100 2 50 4 25 5 20 1031
using
95The divisors of 100 are: 1 100 2 50 4 25 5 20 1034
The divisors of 100 are: 1 2 4 5 10 20 25 50 10075
using
98namespace
9The divisors of 100 are: 1 100 2 50 4 25 5 20 101____537_______9
The divisors of 100 are: 1 2 4 5 10 20 25 50 1006
The divisors of 100 are: 1 100 2 50 4 25 5 20 108
The divisors of 100 are: 1 100 2 50 4 25 5 20 108
namespace
06
PHP
The divisors of 100 are: 1 100 2 50 4 25 5 20 1044
namespace
08
namespace
09
// C++ implementation of Naive method to print all
30
The divisors of 100 are: 1 100 2 50 4 25 5 20 1049
The divisors of 100 are: 1 2 4 5 10 20 25 50 1002_______10_______51
The divisors of 100 are: 1 2 4 5 10 20 25 50 10013
The divisors of 100 are: 1 2 4 5 10 20 25 50 1005
The divisors of 100 are: 1 2 4 5 10 20 25 50 10095
The divisors of 100 are: 1 2 4 5 10 20 25 50 1006
namespace
19The divisors of 100 are: 1 2 4 5 10 20 25 50 1006
namespace
21The divisors of 100 are: 1 2 4 5 10 20 25 50 1006_______0_______7
The divisors of 100 are: 1 2 4 5 10 20 25 50 1008
The divisors of 100 are: 1 100 2 50 4 25 5 20 1057
The divisors of 100 are: 1 100 2 50 4 25 5 20 1058
The divisors of 100 are: 1 100 2 50 4 25 5 20 1057
namespace
28The divisors of 100 are: 1 100 2 50 4 25 5 20 1051
namespace
9The divisors of 100 are: 1 100 2 50 4 25 5 20 1057
The divisors of 100 are: 1 100 2 50 4 25 5 20 1064
The divisors of 100 are: 1 2 4 5 10 20 25 50 1006_______0_______5
The divisors of 100 are: 1 100 2 50 4 25 5 20 101
The divisors of 100 are: 1 100 2 50 4 25 5 20 102
The divisors of 100 are: 1 2 4 5 10 20 25 50 1008
The divisors of 100 are: 1 100 2 50 4 25 5 20 1051_______0_______59
The divisors of 100 are: 1 100 2 50 4 25 5 20 1057
The divisors of 100 are: 1 100 2 50 4 25 5 20 1071
The divisors of 100 are: 1 100 2 50 4 25 5 20 101
The divisors of 100 are: 1 2 4 5 10 20 25 50 1005
#include
67
The divisors of 100 are: 1 100 2 50 4 25 5 20 104
using
55The divisors of 100 are: 1 100 2 50 4 25 5 20 104
using
57The divisors of 100 are: 1 100 2 50 4 25 5 20 104
The divisors of 100 are: 1 100 2 50 4 25 5 20 102
The divisors of 100 are: 1 2 4 5 10 20 25 50 1008
The divisors of 100 are: 1 100 2 50 4 25 5 20 1051
#include
73The divisors of 100 are: 1 100 2 50 4 25 5 20 1057
namespace
55The divisors of 100 are: 1 100 2 50 4 25 5 20 1057
The divisors of 100 are: 1 2 4 5 10 20 25 50 10013
The divisors of 100 are: 1 2 4 5 10 20 25 50 10014
The divisors of 100 are: 1 100 2 50 4 25 5 20 1073
The divisors of 100 are: 1 100 2 50 4 25 5 20 1057
The divisors of 100 are: 1 100 2 50 4 25 5 20 1033
The divisors of 100 are: 1 100 2 50 4 25 5 20 106
The divisors of 100 are: 1 100 2 50 4 25 5 20 1033
The divisors of 100 are: 1 100 2 50 4 25 5 20 1051
#include
73The divisors of 100 are: 1 100 2 50 4 25 5 20 1057
The divisors of 100 are: 1 100 2 50 4 25 5 20 1033
The divisors of 100 are: 1 100 2 50 4 25 5 20 106
// C++ implementation of Naive method to print all
7