Một số nguyên được cho là một số hoàn hảo nếu tổng các yếu tố của nó, bao gồm 1 (nhưng không phải là chính số), bằng số. Ví dụ: 6 là một số hoàn hảo, vì 6 = 1 Show
+ 2 + 3. Viết một hàm hoàn hảo xác định xem số tham số có phải là một số hoàn hảo hay không. Sử dụng chức năng này trong một chương trình xác định và in tất cả các số hoàn hảo trong khoảng từ 1 đến 1000. In các yếu tố của từng số hoàn hảo để xác nhận rằng số này thực sự hoàn hảo.
Tìm hiểu thêm về sự giúp đỡ của chúng tôi với các bài tập: Python Một số nguyên được cho là một con số hoàn hảo nếu các yếu tố của nó, bao gồm 1 (nhưng không phải là chính số), tổng cho số. Ví dụ: 6 là một số hoàn hảo, bởi vì 6 = 1 + 2 + 3. Viết một phương thức hoàn hảo xác định xem số tham số có phải là một số hoàn hảo hay không. Sử dụng phương pháp này trong một ứng dụng xác định và hiển thị tất cả các số hoàn hảo trong khoảng từ 1 đến 1000. Hiển thị các yếu tố của từng số hoàn hảo để xác nhận rằng số thực sự hoàn hảo.
Tìm hiểu thêm về sự giúp đỡ của chúng tôi với các bài tập: Python Đưa ra một số n, nhiệm vụ là tìm tổng của tất cả các yếu tố.examples: & nbsp; & nbsp; Input : n = 30 Output : 72 Dividers sum 1 + 2 + 3 + 5 + 6 + 10 + 15 + 30 = 72 Input : n = 15 Output : 24 Dividers sum 1 + 3 + 5 + 15 = 24 Một giải pháp đơn giản là đi qua tất cả các giao diện và thêm chúng. & Nbsp; & nbsp;simple solution is to traverse through all divisors and add them. C++
0 1 2 1 4 5 6 7 8 9Input : n = 30 Output : 72 Dividers sum 1 + 2 + 3 + 5 + 6 + 10 + 15 + 30 = 72 Input : n = 15 Output : 24 Dividers sum 1 + 3 + 5 + 15 = 240 Input : n = 30 Output : 72 Dividers sum 1 + 2 + 3 + 5 + 6 + 10 + 15 + 30 = 72 Input : n = 15 Output : 24 Dividers sum 1 + 3 + 5 + 15 = 241 6 1 Input : n = 30 Output : 72 Dividers sum 1 + 2 + 3 + 5 + 6 + 10 + 15 + 30 = 72 Input : n = 15 Output : 24 Dividers sum 1 + 3 + 5 + 15 = 244 6Input : n = 30 Output : 72 Dividers sum 1 + 2 + 3 + 5 + 6 + 10 + 15 + 30 = 72 Input : n = 15 Output : 24 Dividers sum 1 + 3 + 5 + 15 = 246 Input : n = 30 Output : 72 Dividers sum 1 + 2 + 3 + 5 + 6 + 10 + 15 + 30 = 72 Input : n = 15 Output : 24 Dividers sum 1 + 3 + 5 + 15 = 247 1 Input : n = 30 Output : 72 Dividers sum 1 + 2 + 3 + 5 + 6 + 10 + 15 + 30 = 72 Input : n = 15 Output : 24 Dividers sum 1 + 3 + 5 + 15 = 249 720 721 6 5724 7 726 724 5729 7 Sum of divisors = (1 + p1 + p12 ... p1a1) * (1 + p2 + p22 ... p2a2) * ............................................. (1 + pk + pk2 ... pkak) We can notice that individual terms of above formula are Geometric Progressions (GP). We can rewrite the formula as. Sum of divisors = (p1a1+1 - 1)/(p1 -1) * (p2a2+1 - 1)/(p2 -1) * .................................. (pkak+1 - 1)/(pk -1)1 Sum of divisors = (1 + p1 + p12 ... p1a1) * (1 + p2 + p22 ... p2a2) * ............................................. (1 + pk + pk2 ... pkak) We can notice that individual terms of above formula are Geometric Progressions (GP). We can rewrite the formula as. Sum of divisors = (p1a1+1 - 1)/(p1 -1) * (p2a2+1 - 1)/(p2 -1) * .................................. (pkak+1 - 1)/(pk -1)2 Sum of divisors = (1 + p1 + p12 ... p1a1) * (1 + p2 + p22 ... p2a2) * ............................................. (1 + pk + pk2 ... pkak) We can notice that individual terms of above formula are Geometric Progressions (GP). We can rewrite the formula as. Sum of divisors = (p1a1+1 - 1)/(p1 -1) * (p2a2+1 - 1)/(p2 -1) * .................................. (pkak+1 - 1)/(pk -1)3 729 Sum of divisors = (1 + p1 + p12 ... p1a1) * (1 + p2 + p22 ... p2a2) * ............................................. (1 + pk + pk2 ... pkak) We can notice that individual terms of above formula are Geometric Progressions (GP). We can rewrite the formula as. Sum of divisors = (p1a1+1 - 1)/(p1 -1) * (p2a2+1 - 1)/(p2 -1) * .................................. (pkak+1 - 1)/(pk -1)5 Sum of divisors = (1 + p1 + p12 ... p1a1) * (1 + p2 + p22 ... p2a2) * ............................................. (1 + pk + pk2 ... pkak) We can notice that individual terms of above formula are Geometric Progressions (GP). We can rewrite the formula as. Sum of divisors = (p1a1+1 - 1)/(p1 -1) * (p2a2+1 - 1)/(p2 -1) * .................................. (pkak+1 - 1)/(pk -1)2 Sum of divisors = (1 + p1 + p12 ... p1a1) * (1 + p2 + p22 ... p2a2) * ............................................. (1 + pk + pk2 ... pkak) We can notice that individual terms of above formula are Geometric Progressions (GP). We can rewrite the formula as. Sum of divisors = (p1a1+1 - 1)/(p1 -1) * (p2a2+1 - 1)/(p2 -1) * .................................. (pkak+1 - 1)/(pk -1)7 724 Sum of divisors = (1 + p1 + p12 ... p1a1) * (1 + p2 + p22 ... p2a2) * ............................................. (1 + pk + pk2 ... pkak) We can notice that individual terms of above formula are Geometric Progressions (GP). We can rewrite the formula as. Sum of divisors = (p1a1+1 - 1)/(p1 -1) * (p2a2+1 - 1)/(p2 -1) * .................................. (pkak+1 - 1)/(pk -1)9 6Sum of divisors = (1 + p1 + p12 ... p1a1) * (1 + p2 + p22 ... p2a2) * ............................................. (1 + pk + pk2 ... pkak) We can notice that individual terms of above formula are Geometric Progressions (GP). We can rewrite the formula as. Sum of divisors = (p1a1+1 - 1)/(p1 -1) * (p2a2+1 - 1)/(p2 -1) * .................................. (pkak+1 - 1)/(pk -1)9 6Input : n = 30 Output : 72 Dividers sum 1 + 2 + 3 + 5 + 6 + 10 + 15 + 30 = 72 Input : n = 15 Output : 24 Dividers sum 1 + 3 + 5 + 15 = 240 Consider the number 18. Sum of factors = 1 + 2 + 3 + 6 + 9 + 18 Writing divisors as powers of prime factors. Sum of factors = (20)(30) + (21)(30) + (2^0)(31) + (21)(31) + (20)(3^2) + (2^1)(32) = (20)(30) + (2^0)(31) + (2^0)(32) + (21)(3^0) + (21)(31) + (21)(32) = (20)(30 + 31 + 32) + (21)(30 + 31 + 32) = (20 + 21)(30 + 31 + 32) If we take a closer look, we can notice that the above expression is in the form. (1 + p1) * (1 + p2 + p22) Where p1 = 2 and p2 = 3 and 18 = 21324 Sum of divisors = (1 + p1 + p12 ... p1a1) * (1 + p2 + p22 ... p2a2) * ............................................. (1 + pk + pk2 ... pkak) We can notice that individual terms of above formula are Geometric Progressions (GP). We can rewrite the formula as. Sum of divisors = (p1a1+1 - 1)/(p1 -1) * (p2a2+1 - 1)/(p2 -1) * .................................. (pkak+1 - 1)/(pk -1)9 1 Consider the number 18. Sum of factors = 1 + 2 + 3 + 6 + 9 + 18 Writing divisors as powers of prime factors. Sum of factors = (20)(30) + (21)(30) + (2^0)(31) + (21)(31) + (20)(3^2) + (2^1)(32) = (20)(30) + (2^0)(31) + (2^0)(32) + (21)(3^0) + (21)(31) + (21)(32) = (20)(30 + 31 + 32) + (21)(30 + 31 + 32) = (20 + 21)(30 + 31 + 32) If we take a closer look, we can notice that the above expression is in the form. (1 + p1) * (1 + p2 + p22) Where p1 = 2 and p2 = 3 and 18 = 21327 5 6 1 721 6723 6Input : n = 30 Output : 72 Dividers sum 1 + 2 + 3 + 5 + 6 + 10 + 15 + 30 = 72 Input : n = 15 Output : 24 Dividers sum 1 + 3 + 5 + 15 = 240 726 Sum of divisors = (1 + p1 + p12 ... p1a1) * (1 + p2 + p22 ... p2a2) * ............................................. (1 + pk + pk2 ... pkak) We can notice that individual terms of above formula are Geometric Progressions (GP). We can rewrite the formula as. Sum of divisors = (p1a1+1 - 1)/(p1 -1) * (p2a2+1 - 1)/(p2 -1) * .................................. (pkak+1 - 1)/(pk -1)9 Java728 729
6#include<bits/stdc++.h> 3 1 2 1 4 6 5
7using 2using 3using 4
Input : n = 30 Output : 72 Dividers sum 1 + 2 + 3 + 5 + 6 + 10 + 15 + 30 = 72 Input : n = 15 Output : 24 Dividers sum 1 + 3 + 5 + 15 = 240 using 3using 8724 1 namespace 1namespace 2using 8724 Input : n = 30 Output : 72 Dividers sum 1 + 2 + 3 + 5 + 6 + 10 + 15 + 30 = 72 Input : n = 15 Output : 24 Dividers sum 1 + 3 + 5 + 15 = 246 Input : n = 30 Output : 72 Dividers sum 1 + 2 + 3 + 5 + 6 + 10 + 15 + 30 = 72 Input : n = 15 Output : 24 Dividers sum 1 + 3 + 5 + 15 = 247 1 namespace 8namespace 9 00724 5729 7 05namespace 2using 4729 5Sum of divisors = (1 + p1 + p12 ... p1a1) * (1 + p2 + p22 ... p2a2) * ............................................. (1 + pk + pk2 ... pkak) We can notice that individual terms of above formula are Geometric Progressions (GP). We can rewrite the formula as. Sum of divisors = (p1a1+1 - 1)/(p1 -1) * (p2a2+1 - 1)/(p2 -1) * .................................. (pkak+1 - 1)/(pk -1)2 7 Sum of divisors = (1 + p1 + p12 ... p1a1) * (1 + p2 + p22 ... p2a2) * ............................................. (1 + pk + pk2 ... pkak) We can notice that individual terms of above formula are Geometric Progressions (GP). We can rewrite the formula as. Sum of divisors = (p1a1+1 - 1)/(p1 -1) * (p2a2+1 - 1)/(p2 -1) * .................................. (pkak+1 - 1)/(pk -1)1 13Sum of divisors = (1 + p1 + p12 ... p1a1) * (1 + p2 + p22 ... p2a2) * ............................................. (1 + pk + pk2 ... pkak) We can notice that individual terms of above formula are Geometric Progressions (GP). We can rewrite the formula as. Sum of divisors = (p1a1+1 - 1)/(p1 -1) * (p2a2+1 - 1)/(p2 -1) * .................................. (pkak+1 - 1)/(pk -1)3 Sum of divisors = (1 + p1 + p12 ... p1a1) * (1 + p2 + p22 ... p2a2) * ............................................. (1 + pk + pk2 ... pkak) We can notice that individual terms of above formula are Geometric Progressions (GP). We can rewrite the formula as. Sum of divisors = (p1a1+1 - 1)/(p1 -1) * (p2a2+1 - 1)/(p2 -1) * .................................. (pkak+1 - 1)/(pk -1)2 Sum of divisors = (1 + p1 + p12 ... p1a1) * (1 + p2 + p22 ... p2a2) * ............................................. (1 + pk + pk2 ... pkak) We can notice that individual terms of above formula are Geometric Progressions (GP). We can rewrite the formula as. Sum of divisors = (p1a1+1 - 1)/(p1 -1) * (p2a2+1 - 1)/(p2 -1) * .................................. (pkak+1 - 1)/(pk -1)5 13 18729 Sum of divisors = (1 + p1 + p12 ... p1a1) * (1 + p2 + p22 ... p2a2) * ............................................. (1 + pk + pk2 ... pkak) We can notice that individual terms of above formula are Geometric Progressions (GP). We can rewrite the formula as. Sum of divisors = (p1a1+1 - 1)/(p1 -1) * (p2a2+1 - 1)/(p2 -1) * .................................. (pkak+1 - 1)/(pk -1)9 724 Sum of divisors = (1 + p1 + p12 ... p1a1) * (1 + p2 + p22 ... p2a2) * ............................................. (1 + pk + pk2 ... pkak) We can notice that individual terms of above formula are Geometric Progressions (GP). We can rewrite the formula as. Sum of divisors = (p1a1+1 - 1)/(p1 -1) * (p2a2+1 - 1)/(p2 -1) * .................................. (pkak+1 - 1)/(pk -1)9 724 Input : n = 30 Output : 72 Dividers sum 1 + 2 + 3 + 5 + 6 + 10 + 15 + 30 = 72 Input : n = 15 Output : 24 Dividers sum 1 + 3 + 5 + 15 = 240 25using 3 27 6Sum of divisors = (1 + p1 + p12 ... p1a1) * (1 + p2 + p22 ... p2a2) * ............................................. (1 + pk + pk2 ... pkak) We can notice that individual terms of above formula are Geometric Progressions (GP). We can rewrite the formula as. Sum of divisors = (p1a1+1 - 1)/(p1 -1) * (p2a2+1 - 1)/(p2 -1) * .................................. (pkak+1 - 1)/(pk -1)9 6 31 #include<bits/stdc++.h> 3 33 34 6 5724 1 39 40using 8724 43 6Sum of divisors = (1 + p1 + p12 ... p1a1) * (1 + p2 + p22 ... p2a2) * ............................................. (1 + pk + pk2 ... pkak) We can notice that individual terms of above formula are Geometric Progressions (GP). We can rewrite the formula as. Sum of divisors = (p1a1+1 - 1)/(p1 -1) * (p2a2+1 - 1)/(p2 -1) * .................................. (pkak+1 - 1)/(pk -1)9 Sum of divisors = (1 + p1 + p12 ... p1a1) * (1 + p2 + p22 ... p2a2) * ............................................. (1 + pk + pk2 ... pkak) We can notice that individual terms of above formula are Geometric Progressions (GP). We can rewrite the formula as. Sum of divisors = (p1a1+1 - 1)/(p1 -1) * (p2a2+1 - 1)/(p2 -1) * .................................. (pkak+1 - 1)/(pk -1)9 Python3728 48 49 50 6 7 53 54 54 using 3 57 58Input : n = 30 Output : 72 Dividers sum 1 + 2 + 3 + 5 + 6 + 10 + 15 + 30 = 72 Input : n = 15 Output : 24 Dividers sum 1 + 3 + 5 + 15 = 240 using 3 6 62 54 namespace 2 6Input : n = 30 Output : 72 Dividers sum 1 + 2 + 3 + 5 + 6 + 10 + 15 + 30 = 72 Input : n = 15 Output : 24 Dividers sum 1 + 3 + 5 + 15 = 246 67 68 69Input : n = 30 Output : 72 Dividers sum 1 + 2 + 3 + 5 + 6 + 10 + 15 + 30 = 72 Input : n = 15 Output : 24 Dividers sum 1 + 3 + 5 + 15 = 247 namespace 9 72 1 ____724 7 53 81 67 54__729 7 89 54 54 92 93 94Sum of divisors = (1 + p1 + p12 ... p1a1) * (1 + p2 + p22 ... p2a2) * ............................................. (1 + pk + pk2 ... pkak) We can notice that individual terms of above formula are Geometric Progressions (GP). We can rewrite the formula as. Sum of divisors = (p1a1+1 - 1)/(p1 -1) * (p2a2+1 - 1)/(p2 -1) * .................................. (pkak+1 - 1)/(pk -1)2 62 54 62 75 Input : n = 30 Output : 72 Dividers sum 1 + 2 + 3 + 5 + 6 + 10 + 15 + 30 = 72 Input : n = 15 Output : 24 Dividers sum 1 + 3 + 5 + 15 = 2400 729 Sum of divisors = (1 + p1 + p12 ... p1a1) * (1 + p2 + p22 ... p2a2) * ............................................. (1 + pk + pk2 ... pkak) We can notice that individual terms of above formula are Geometric Progressions (GP). We can rewrite the formula as. Sum of divisors = (p1a1+1 - 1)/(p1 -1) * (p2a2+1 - 1)/(p2 -1) * .................................. (pkak+1 - 1)/(pk -1)5 Input : n = 30 Output : 72 Dividers sum 1 + 2 + 3 + 5 + 6 + 10 + 15 + 30 = 72 Input : n = 15 Output : 24 Dividers sum 1 + 3 + 5 + 15 = 2403 Sum of divisors = (1 + p1 + p12 ... p1a1) * (1 + p2 + p22 ... p2a2) * ............................................. (1 + pk + pk2 ... pkak) We can notice that individual terms of above formula are Geometric Progressions (GP). We can rewrite the formula as. Sum of divisors = (p1a1+1 - 1)/(p1 -1) * (p2a2+1 - 1)/(p2 -1) * .................................. (pkak+1 - 1)/(pk -1)2 62 54 62 75 89 75 6Input : n = 30 Output : 72 Dividers sum 1 + 2 + 3 + 5 + 6 + 10 + 15 + 30 = 72 Input : n = 15 Output : 24 Dividers sum 1 + 3 + 5 + 15 = 240 Input : n = 30 Output : 72 Dividers sum 1 + 2 + 3 + 5 + 6 + 10 + 15 + 30 = 72 Input : n = 15 Output : 24 Dividers sum 1 + 3 + 5 + 15 = 2417 75 Input : n = 30 Output : 72 Dividers sum 1 + 2 + 3 + 5 + 6 + 10 + 15 + 30 = 72 Input : n = 15 Output : 24 Dividers sum 1 + 3 + 5 + 15 = 2419 75Input : n = 30 Output : 72 Dividers sum 1 + 2 + 3 + 5 + 6 + 10 + 15 + 30 = 72 Input : n = 15 Output : 24 Dividers sum 1 + 3 + 5 + 15 = 2419 54 40Input : n = 30 Output : 72 Dividers sum 1 + 2 + 3 + 5 + 6 + 10 + 15 + 30 = 72 Input : n = 15 Output : 24 Dividers sum 1 + 3 + 5 + 15 = 2426 Input : n = 30 Output : 72 Dividers sum 1 + 2 + 3 + 5 + 6 + 10 + 15 + 30 = 72 Input : n = 15 Output : 24 Dividers sum 1 + 3 + 5 + 15 = 2427 C#
Input : n = 30 Output : 72 Dividers sum 1 + 2 + 3 + 5 + 6 + 10 + 15 + 30 = 72 Input : n = 15 Output : 24 Dividers sum 1 + 3 + 5 + 15 = 2429
6#include<bits/stdc++.h> 3 1 2 1 4 6 5724 7 8
Input : n = 30 Output : 72 Dividers sum 1 + 2 + 3 + 5 + 6 + 10 + 15 + 30 = 72 Input : n = 15 Output : 24 Dividers sum 1 + 3 + 5 + 15 = 240 Input : n = 30 Output : 72 Dividers sum 1 + 2 + 3 + 5 + 6 + 10 + 15 + 30 = 72 Input : n = 15 Output : 24 Dividers sum 1 + 3 + 5 + 15 = 241 724 1 Input : n = 30 Output : 72 Dividers sum 1 + 2 + 3 + 5 + 6 + 10 + 15 + 30 = 72 Input : n = 15 Output : 24 Dividers sum 1 + 3 + 5 + 15 = 244 724 Input : n = 30 Output : 72 Dividers sum 1 + 2 + 3 + 5 + 6 + 10 + 15 + 30 = 72 Input : n = 15 Output : 24 Dividers sum 1 + 3 + 5 + 15 = 246 Input : n = 30 Output : 72 Dividers sum 1 + 2 + 3 + 5 + 6 + 10 + 15 + 30 = 72 Input : n = 15 Output : 24 Dividers sum 1 + 3 + 5 + 15 = 247 1 Input : n = 30 Output : 72 Dividers sum 1 + 2 + 3 + 5 + 6 + 10 + 15 + 30 = 72 Input : n = 15 Output : 24 Dividers sum 1 + 3 + 5 + 15 = 2453 724 5729 7 726 729 5Sum of divisors = (1 + p1 + p12 ... p1a1) * (1 + p2 + p22 ... p2a2) * ............................................. (1 + pk + pk2 ... pkak) We can notice that individual terms of above formula are Geometric Progressions (GP). We can rewrite the formula as. Sum of divisors = (p1a1+1 - 1)/(p1 -1) * (p2a2+1 - 1)/(p2 -1) * .................................. (pkak+1 - 1)/(pk -1)2 7 Sum of divisors = (1 + p1 + p12 ... p1a1) * (1 + p2 + p22 ... p2a2) * ............................................. (1 + pk + pk2 ... pkak) We can notice that individual terms of above formula are Geometric Progressions (GP). We can rewrite the formula as. Sum of divisors = (p1a1+1 - 1)/(p1 -1) * (p2a2+1 - 1)/(p2 -1) * .................................. (pkak+1 - 1)/(pk -1)1 13Sum of divisors = (1 + p1 + p12 ... p1a1) * (1 + p2 + p22 ... p2a2) * ............................................. (1 + pk + pk2 ... pkak) We can notice that individual terms of above formula are Geometric Progressions (GP). We can rewrite the formula as. Sum of divisors = (p1a1+1 - 1)/(p1 -1) * (p2a2+1 - 1)/(p2 -1) * .................................. (pkak+1 - 1)/(pk -1)3 Sum of divisors = (1 + p1 + p12 ... p1a1) * (1 + p2 + p22 ... p2a2) * ............................................. (1 + pk + pk2 ... pkak) We can notice that individual terms of above formula are Geometric Progressions (GP). We can rewrite the formula as. Sum of divisors = (p1a1+1 - 1)/(p1 -1) * (p2a2+1 - 1)/(p2 -1) * .................................. (pkak+1 - 1)/(pk -1)2 Sum of divisors = (1 + p1 + p12 ... p1a1) * (1 + p2 + p22 ... p2a2) * ............................................. (1 + pk + pk2 ... pkak) We can notice that individual terms of above formula are Geometric Progressions (GP). We can rewrite the formula as. Sum of divisors = (p1a1+1 - 1)/(p1 -1) * (p2a2+1 - 1)/(p2 -1) * .................................. (pkak+1 - 1)/(pk -1)5 13 18729 Sum of divisors = (1 + p1 + p12 ... p1a1) * (1 + p2 + p22 ... p2a2) * ............................................. (1 + pk + pk2 ... pkak) We can notice that individual terms of above formula are Geometric Progressions (GP). We can rewrite the formula as. Sum of divisors = (p1a1+1 - 1)/(p1 -1) * (p2a2+1 - 1)/(p2 -1) * .................................. (pkak+1 - 1)/(pk -1)9 724 Sum of divisors = (1 + p1 + p12 ... p1a1) * (1 + p2 + p22 ... p2a2) * ............................................. (1 + pk + pk2 ... pkak) We can notice that individual terms of above formula are Geometric Progressions (GP). We can rewrite the formula as. Sum of divisors = (p1a1+1 - 1)/(p1 -1) * (p2a2+1 - 1)/(p2 -1) * .................................. (pkak+1 - 1)/(pk -1)9 724 Input : n = 30 Output : 72 Dividers sum 1 + 2 + 3 + 5 + 6 + 10 + 15 + 30 = 72 Input : n = 15 Output : 24 Dividers sum 1 + 3 + 5 + 15 = 240 Consider the number 18. Sum of factors = 1 + 2 + 3 + 6 + 9 + 18 Writing divisors as powers of prime factors. Sum of factors = (20)(30) + (21)(30) + (2^0)(31) + (21)(31) + (20)(3^2) + (2^1)(32) = (20)(30) + (2^0)(31) + (2^0)(32) + (21)(3^0) + (21)(31) + (21)(32) = (20)(30 + 31 + 32) + (21)(30 + 31 + 32) = (20 + 21)(30 + 31 + 32) If we take a closer look, we can notice that the above expression is in the form. (1 + p1) * (1 + p2 + p22) Where p1 = 2 and p2 = 3 and 18 = 21324 6Sum of divisors = (1 + p1 + p12 ... p1a1) * (1 + p2 + p22 ... p2a2) * ............................................. (1 + pk + pk2 ... pkak) We can notice that individual terms of above formula are Geometric Progressions (GP). We can rewrite the formula as. Sum of divisors = (p1a1+1 - 1)/(p1 -1) * (p2a2+1 - 1)/(p2 -1) * .................................. (pkak+1 - 1)/(pk -1)9 6 31 #include<bits/stdc++.h> 3 33 Input : n = 30 Output : 72 Dividers sum 1 + 2 + 3 + 5 + 6 + 10 + 15 + 30 = 72 Input : n = 15 Output : 24 Dividers sum 1 + 3 + 5 + 15 = 2483 6 5724 1 721 724 Input : n = 30 Output : 72 Dividers sum 1 + 2 + 3 + 5 + 6 + 10 + 15 + 30 = 72 Input : n = 15 Output : 24 Dividers sum 1 + 3 + 5 + 15 = 2490 6Sum of divisors = (1 + p1 + p12 ... p1a1) * (1 + p2 + p22 ... p2a2) * ............................................. (1 + pk + pk2 ... pkak) We can notice that individual terms of above formula are Geometric Progressions (GP). We can rewrite the formula as. Sum of divisors = (p1a1+1 - 1)/(p1 -1) * (p2a2+1 - 1)/(p2 -1) * .................................. (pkak+1 - 1)/(pk -1)9 Sum of divisors = (1 + p1 + p12 ... p1a1) * (1 + p2 + p22 ... p2a2) * ............................................. (1 + pk + pk2 ... pkak) We can notice that individual terms of above formula are Geometric Progressions (GP). We can rewrite the formula as. Sum of divisors = (p1a1+1 - 1)/(p1 -1) * (p2a2+1 - 1)/(p2 -1) * .................................. (pkak+1 - 1)/(pk -1)9 PHPInput : n = 30 Output : 72 Dividers sum 1 + 2 + 3 + 5 + 6 + 10 + 15 + 30 = 72 Input : n = 15 Output : 24 Dividers sum 1 + 3 + 5 + 15 = 2494 Input : n = 30 Output : 72 Dividers sum 1 + 2 + 3 + 5 + 6 + 10 + 15 + 30 = 72 Input : n = 15 Output : 24 Dividers sum 1 + 3 + 5 + 15 = 2495 2Input : n = 30 Output : 72 Dividers sum 1 + 2 + 3 + 5 + 6 + 10 + 15 + 30 = 72 Input : n = 15 Output : 24 Dividers sum 1 + 3 + 5 + 15 = 2497 using 4 5 6 7Input : n = 30 Output : 72 Dividers sum 1 + 2 + 3 + 5 + 6 + 10 + 15 + 30 = 72 Input : n = 15 Output : 24 Dividers sum 1 + 3 + 5 + 15 = 247 Input : n = 30 Output : 72 Dividers sum 1 + 2 + 3 + 5 + 6 + 10 + 15 + 30 = 72 Input : n = 15 Output : 24 Dividers sum 1 + 3 + 5 + 15 = 2497 7204 9Input : n = 30 Output : 72 Dividers sum 1 + 2 + 3 + 5 + 6 + 10 + 15 + 30 = 72 Input : n = 15 Output : 24 Dividers sum 1 + 3 + 5 + 15 = 240 Input : n = 30 Output : 72 Dividers sum 1 + 2 + 3 + 5 + 6 + 10 + 15 + 30 = 72 Input : n = 15 Output : 24 Dividers sum 1 + 3 + 5 + 15 = 241 67209 7210 6Input : n = 30 Output : 72 Dividers sum 1 + 2 + 3 + 5 + 6 + 10 + 15 + 30 = 72 Input : n = 15 Output : 24 Dividers sum 1 + 3 + 5 + 15 = 246 7213 7214 7215 7214 6 5724 7 Input : n = 30 Output : 72 Dividers sum 1 + 2 + 3 + 5 + 6 + 10 + 15 + 30 = 72 Input : n = 15 Output : 24 Dividers sum 1 + 3 + 5 + 15 = 247 Input : n = 30 Output : 72 Dividers sum 1 + 2 + 3 + 5 + 6 + 10 + 15 + 30 = 72 Input : n = 15 Output : 24 Dividers sum 1 + 3 + 5 + 15 = 2497 7228 7214 7230 724 5729 7 Input : n = 30 Output : 72 Dividers sum 1 + 2 + 3 + 5 + 6 + 10 + 15 + 30 = 72 Input : n = 15 Output : 24 Dividers sum 1 + 3 + 5 + 15 = 247 7214 7237 Input : n = 30 Output : 72 Dividers sum 1 + 2 + 3 + 5 + 6 + 10 + 15 + 30 = 72 Input : n = 15 Output : 24 Dividers sum 1 + 3 + 5 + 15 = 2497 Sum of divisors = (1 + p1 + p12 ... p1a1) * (1 + p2 + p22 ... p2a2) * ............................................. (1 + pk + pk2 ... pkak) We can notice that individual terms of above formula are Geometric Progressions (GP). We can rewrite the formula as. Sum of divisors = (p1a1+1 - 1)/(p1 -1) * (p2a2+1 - 1)/(p2 -1) * .................................. (pkak+1 - 1)/(pk -1)2 7209 7244 7214 using 8729 Sum of divisors = (1 + p1 + p12 ... p1a1) * (1 + p2 + p22 ... p2a2) * ............................................. (1 + pk + pk2 ... pkak) We can notice that individual terms of above formula are Geometric Progressions (GP). We can rewrite the formula as. Sum of divisors = (p1a1+1 - 1)/(p1 -1) * (p2a2+1 - 1)/(p2 -1) * .................................. (pkak+1 - 1)/(pk -1)5 Sum of divisors = (1 + p1 + p12 ... p1a1) * (1 + p2 + p22 ... p2a2) * ............................................. (1 + pk + pk2 ... pkak) We can notice that individual terms of above formula are Geometric Progressions (GP). We can rewrite the formula as. Sum of divisors = (p1a1+1 - 1)/(p1 -1) * (p2a2+1 - 1)/(p2 -1) * .................................. (pkak+1 - 1)/(pk -1)2 7209 7251 7214 7253 Input : n = 30 Output : 72 Dividers sum 1 + 2 + 3 + 5 + 6 + 10 + 15 + 30 = 72 Input : n = 15 Output : 24 Dividers sum 1 + 3 + 5 + 15 = 2497 724 Sum of divisors = (1 + p1 + p12 ... p1a1) * (1 + p2 + p22 ... p2a2) * ............................................. (1 + pk + pk2 ... pkak) We can notice that individual terms of above formula are Geometric Progressions (GP). We can rewrite the formula as. Sum of divisors = (p1a1+1 - 1)/(p1 -1) * (p2a2+1 - 1)/(p2 -1) * .................................. (pkak+1 - 1)/(pk -1)9 6Sum of divisors = (1 + p1 + p12 ... p1a1) * (1 + p2 + p22 ... p2a2) * ............................................. (1 + pk + pk2 ... pkak) We can notice that individual terms of above formula are Geometric Progressions (GP). We can rewrite the formula as. Sum of divisors = (p1a1+1 - 1)/(p1 -1) * (p2a2+1 - 1)/(p2 -1) * .................................. (pkak+1 - 1)/(pk -1)9 6Input : n = 30 Output : 72 Dividers sum 1 + 2 + 3 + 5 + 6 + 10 + 15 + 30 = 72 Input : n = 15 Output : 24 Dividers sum 1 + 3 + 5 + 15 = 240 Input : n = 30 Output : 72 Dividers sum 1 + 2 + 3 + 5 + 6 + 10 + 15 + 30 = 72 Input : n = 15 Output : 24 Dividers sum 1 + 3 + 5 + 15 = 247 7209 7253 Input : n = 30 Output : 72 Dividers sum 1 + 2 + 3 + 5 + 6 + 10 + 15 + 30 = 72 Input : n = 15 Output : 24 Dividers sum 1 + 3 + 5 + 15 = 2497 7268 Sum of divisors = (1 + p1 + p12 ... p1a1) * (1 + p2 + p22 ... p2a2) * ............................................. (1 + pk + pk2 ... pkak) We can notice that individual terms of above formula are Geometric Progressions (GP). We can rewrite the formula as. Sum of divisors = (p1a1+1 - 1)/(p1 -1) * (p2a2+1 - 1)/(p2 -1) * .................................. (pkak+1 - 1)/(pk -1)9 Input : n = 30 Output : 72 Dividers sum 1 + 2 + 3 + 5 + 6 + 10 + 15 + 30 = 72 Input : n = 15 Output : 24 Dividers sum 1 + 3 + 5 + 15 = 2497 7271 7272 2Input : n = 30 Output : 72 Dividers sum 1 + 2 + 3 + 5 + 6 + 10 + 15 + 30 = 72 Input : n = 15 Output : 24 Dividers sum 1 + 3 + 5 + 15 = 2497 277276 JavaScript7277 Input : n = 30 Output : 72 Dividers sum 1 + 2 + 3 + 5 + 6 + 10 + 15 + 30 = 72 Input : n = 15 Output : 24 Dividers sum 1 + 3 + 5 + 15 = 2495 7279 5 6 7 8
9Input : n = 30 Output : 72 Dividers sum 1 + 2 + 3 + 5 + 6 + 10 + 15 + 30 = 72 Input : n = 15 Output : 24 Dividers sum 1 + 3 + 5 + 15 = 240 Input : n = 30 Output : 72 Dividers sum 1 + 2 + 3 + 5 + 6 + 10 + 15 + 30 = 72 Input : n = 15 Output : 24 Dividers sum 1 + 3 + 5 + 15 = 241 67288 67209 7210 6 5 6Input : n = 30 Output : 72 Dividers sum 1 + 2 + 3 + 5 + 6 + 10 + 15 + 30 = 72 Input : n = 15 Output : 24 Dividers sum 1 + 3 + 5 + 15 = 246 7213 7214 7215 7214 724 5724 7 Input : n = 30 Output : 72 Dividers sum 1 + 2 + 3 + 5 + 6 + 10 + 15 + 30 = 72 Input : n = 15 Output : 24 Dividers sum 1 + 3 + 5 + 15 = 247 Input : n = 30 Output : 72 Dividers sum 1 + 2 + 3 + 5 + 6 + 10 + 15 + 30 = 72 Input : n = 15 Output : 24 Dividers sum 1 + 3 + 5 + 15 = 2497 7228 7214 7230 Sum of divisors = (1 + p1 + p12 ... p1a1) * (1 + p2 + p22 ... p2a2) * ............................................. (1 + pk + pk2 ... pkak) We can notice that individual terms of above formula are Geometric Progressions (GP). We can rewrite the formula as. Sum of divisors = (p1a1+1 - 1)/(p1 -1) * (p2a2+1 - 1)/(p2 -1) * .................................. (pkak+1 - 1)/(pk -1)2 Sum of divisors = (1 + p1 + p12 ... p1a1) * (1 + p2 + p22 ... p2a2) * ............................................. (1 + pk + pk2 ... pkak) We can notice that individual terms of above formula are Geometric Progressions (GP). We can rewrite the formula as. Sum of divisors = (p1a1+1 - 1)/(p1 -1) * (p2a2+1 - 1)/(p2 -1) * .................................. (pkak+1 - 1)/(pk -1)3 729 Sum of divisors = (1 + p1 + p12 ... p1a1) * (1 + p2 + p22 ... p2a2) * ............................................. (1 + pk + pk2 ... pkak) We can notice that individual terms of above formula are Geometric Progressions (GP). We can rewrite the formula as. Sum of divisors = (p1a1+1 - 1)/(p1 -1) * (p2a2+1 - 1)/(p2 -1) * .................................. (pkak+1 - 1)/(pk -1)5 Sum of divisors = (1 + p1 + p12 ... p1a1) * (1 + p2 + p22 ... p2a2) * ............................................. (1 + pk + pk2 ... pkak) We can notice that individual terms of above formula are Geometric Progressions (GP). We can rewrite the formula as. Sum of divisors = (p1a1+1 - 1)/(p1 -1) * (p2a2+1 - 1)/(p2 -1) * .................................. (pkak+1 - 1)/(pk -1)2 18724 Sum of divisors = (1 + p1 + p12 ... p1a1) * (1 + p2 + p22 ... p2a2) * ............................................. (1 + pk + pk2 ... pkak) We can notice that individual terms of above formula are Geometric Progressions (GP). We can rewrite the formula as. Sum of divisors = (p1a1+1 - 1)/(p1 -1) * (p2a2+1 - 1)/(p2 -1) * .................................. (pkak+1 - 1)/(pk -1)9 6Sum of divisors = (1 + p1 + p12 ... p1a1) * (1 + p2 + p22 ... p2a2) * ............................................. (1 + pk + pk2 ... pkak) We can notice that individual terms of above formula are Geometric Progressions (GP). We can rewrite the formula as. Sum of divisors = (p1a1+1 - 1)/(p1 -1) * (p2a2+1 - 1)/(p2 -1) * .................................. (pkak+1 - 1)/(pk -1)9 729 7 Input : n = 30 Output : 72 Dividers sum 1 + 2 + 3 + 5 + 6 + 10 + 15 + 30 = 72 Input : n = 15 Output : 24 Dividers sum 1 + 3 + 5 + 15 = 247 7214 7237 Input : n = 30 Output : 72 Dividers sum 1 + 2 + 3 + 5 + 6 + 10 + 15 + 30 = 72 Input : n = 15 Output : 24 Dividers sum 1 + 3 + 5 + 15 = 2497 Sum of divisors = (1 + p1 + p12 ... p1a1) * (1 + p2 + p22 ... p2a2) * ............................................. (1 + pk + pk2 ... pkak) We can notice that individual terms of above formula are Geometric Progressions (GP). We can rewrite the formula as. Sum of divisors = (p1a1+1 - 1)/(p1 -1) * (p2a2+1 - 1)/(p2 -1) * .................................. (pkak+1 - 1)/(pk -1)9 Sum of divisors = (1 + p1 + p12 ... p1a1) * (1 + p2 + p22 ... p2a2) * ............................................. (1 + pk + pk2 ... pkak) We can notice that individual terms of above formula are Geometric Progressions (GP). We can rewrite the formula as. Sum of divisors = (p1a1+1 - 1)/(p1 -1) * (p2a2+1 - 1)/(p2 -1) * .................................. (pkak+1 - 1)/(pk -1)16 Sum of divisors = (1 + p1 + p12 ... p1a1) * (1 + p2 + p22 ... p2a2) * ............................................. (1 + pk + pk2 ... pkak) We can notice that individual terms of above formula are Geometric Progressions (GP). We can rewrite the formula as. Sum of divisors = (p1a1+1 - 1)/(p1 -1) * (p2a2+1 - 1)/(p2 -1) * .................................. (pkak+1 - 1)/(pk -1)17 Sum of divisors = (1 + p1 + p12 ... p1a1) * (1 + p2 + p22 ... p2a2) * ............................................. (1 + pk + pk2 ... pkak) We can notice that individual terms of above formula are Geometric Progressions (GP). We can rewrite the formula as. Sum of divisors = (p1a1+1 - 1)/(p1 -1) * (p2a2+1 - 1)/(p2 -1) * .................................. (pkak+1 - 1)/(pk -1)18
72
6Input : n = 30 Output : 72 Dividers sum 1 + 2 + 3 + 5 + 6 + 10 + 15 + 30 = 72 Input : n = 15 Output : 24 Dividers sum 1 + 3 + 5 + 15 = 240 Input : n = 30 Output : 72 Dividers sum 1 + 2 + 3 + 5 + 6 + 10 + 15 + 30 = 72 Input : n = 15 Output : 24 Dividers sum 1 + 3 + 5 + 15 = 247 7209 7253 Input : n = 30 Output : 72 Dividers sum 1 + 2 + 3 + 5 + 6 + 10 + 15 + 30 = 72 Input : n = 15 Output : 24 Dividers sum 1 + 3 + 5 + 15 = 2497 7268efficient solution is to use below formula. Let p1, p2, … pk be prime factors of n. Let a1, a2, .. ak be highest powers of p1, p2, .. pk respectively that divide n, i.e., we can write n as n = (p1a1)*(p2a2)* … (pkak). Sum of divisors = (1 + p1 + p12 ... p1a1) * (1 + p2 + p22 ... p2a2) * ............................................. (1 + pk + pk2 ... pkak) We can notice that individual terms of above formula are Geometric Progressions (GP). We can rewrite the formula as. Sum of divisors = (p1a1+1 - 1)/(p1 -1) * (p2a2+1 - 1)/(p2 -1) * .................................. (pkak+1 - 1)/(pk -1)
Consider the number 18. Sum of factors = 1 + 2 + 3 + 6 + 9 + 18 Writing divisors as powers of prime factors. Sum of factors = (20)(30) + (21)(30) + (2^0)(31) + (21)(31) + (20)(3^2) + (2^1)(32) = (20)(30) + (2^0)(31) + (2^0)(32) + (21)(3^0) + (21)(31) + (21)(32) = (20)(30 + 31 + 32) + (21)(30 + 31 + 32) = (20 + 21)(30 + 31 + 32) If we take a closer look, we can notice that the above expression is in the form. (1 + p1) * (1 + p2 + p22) Where p1 = 2 and p2 = 3 and 18 = 2132 7272 2Input : n = 30 Output : 72 Dividers sum 1 + 2 + 3 + 5 + 6 + 10 + 15 + 30 = 72 Input : n = 15 Output : 24 Dividers sum 1 + 3 + 5 + 15 = 2497 27C++Sum of divisors = (1 + p1 + p12 ... p1a1) * (1 + p2 + p22 ... p2a2) * ............................................. (1 + pk + pk2 ... pkak) We can notice that individual terms of above formula are Geometric Progressions (GP). We can rewrite the formula as. Sum of divisors = (p1a1+1 - 1)/(p1 -1) * (p2a2+1 - 1)/(p2 -1) * .................................. (pkak+1 - 1)/(pk -1)19 JavaScript Input : n = 30 Output : 72 Dividers sum 1 + 2 + 3 + 5 + 6 + 10 + 15 + 30 = 72 Input : n = 15 Output : 24 Dividers sum 1 + 3 + 5 + 15 = 2495 7279 5 6Input : n = 30 Output : 72 Dividers sum 1 + 2 + 3 + 5 + 6 + 10 + 15 + 30 = 72 Input : n = 15 Output : 24 Dividers sum 1 + 3 + 5 + 15 = 246 7291 724 7 726 6 5729 7 Sum of divisors = (1 + p1 + p12 ... p1a1) * (1 + p2 + p22 ... p2a2) * ............................................. (1 + pk + pk2 ... pkak) We can notice that individual terms of above formula are Geometric Progressions (GP). We can rewrite the formula as. Sum of divisors = (p1a1+1 - 1)/(p1 -1) * (p2a2+1 - 1)/(p2 -1) * .................................. (pkak+1 - 1)/(pk -1)1 6Input : n = 30 Output : 72 Dividers sum 1 + 2 + 3 + 5 + 6 + 10 + 15 + 30 = 72 Input : n = 15 Output : 24 Dividers sum 1 + 3 + 5 + 15 = 240 Consider the number 18. Sum of factors = 1 + 2 + 3 + 6 + 9 + 18 Writing divisors as powers of prime factors. Sum of factors = (20)(30) + (21)(30) + (2^0)(31) + (21)(31) + (20)(3^2) + (2^1)(32) = (20)(30) + (2^0)(31) + (2^0)(32) + (21)(3^0) + (21)(31) + (21)(32) = (20)(30 + 31 + 32) + (21)(30 + 31 + 32) = (20 + 21)(30 + 31 + 32) If we take a closer look, we can notice that the above expression is in the form. (1 + p1) * (1 + p2 + p22) Where p1 = 2 and p2 = 3 and 18 = 21324 Đầu ra: & nbsp; & nbsp; 729 Sum of divisors = (1 + p1 + p12 ... p1a1) * (1 + p2 + p22 ... p2a2) * ............................................. (1 + pk + pk2 ... pkak) We can notice that individual terms of above formula are Geometric Progressions (GP). We can rewrite the formula as. Sum of divisors = (p1a1+1 - 1)/(p1 -1) * (p2a2+1 - 1)/(p2 -1) * .................................. (pkak+1 - 1)/(pk -1)50 729 Sum of divisors = (1 + p1 + p12 ... p1a1) * (1 + p2 + p22 ... p2a2) * ............................................. (1 + pk + pk2 ... pkak) We can notice that individual terms of above formula are Geometric Progressions (GP). We can rewrite the formula as. Sum of divisors = (p1a1+1 - 1)/(p1 -1) * (p2a2+1 - 1)/(p2 -1) * .................................. (pkak+1 - 1)/(pk -1)52 729 Sum of divisors = (1 + p1 + p12 ... p1a1) * (1 + p2 + p22 ... p2a2) * ............................................. (1 + pk + pk2 ... pkak) We can notice that individual terms of above formula are Geometric Progressions (GP). We can rewrite the formula as. Sum of divisors = (p1a1+1 - 1)/(p1 -1) * (p2a2+1 - 1)/(p2 -1) * .................................. (pkak+1 - 1)/(pk -1)54 724 Sum of divisors = (1 + p1 + p12 ... p1a1) * (1 + p2 + p22 ... p2a2) * ............................................. (1 + pk + pk2 ... pkak) We can notice that individual terms of above formula are Geometric Progressions (GP). We can rewrite the formula as. Sum of divisors = (p1a1+1 - 1)/(p1 -1) * (p2a2+1 - 1)/(p2 -1) * .................................. (pkak+1 - 1)/(pk -1)9 724 Sum of divisors = (1 + p1 + p12 ... p1a1) * (1 + p2 + p22 ... p2a2) * ............................................. (1 + pk + pk2 ... pkak) We can notice that individual terms of above formula are Geometric Progressions (GP). We can rewrite the formula as. Sum of divisors = (p1a1+1 - 1)/(p1 -1) * (p2a2+1 - 1)/(p2 -1) * .................................. (pkak+1 - 1)/(pk -1)58 6Sum of divisors = (1 + p1 + p12 ... p1a1) * (1 + p2 + p22 ... p2a2) * ............................................. (1 + pk + pk2 ... pkak) We can notice that individual terms of above formula are Geometric Progressions (GP). We can rewrite the formula as. Sum of divisors = (p1a1+1 - 1)/(p1 -1) * (p2a2+1 - 1)/(p2 -1) * .................................. (pkak+1 - 1)/(pk -1)9 Độ phức tạp về thời gian: O (√n) & nbsp; không gian phụ trợ: O (1) 724 Sum of divisors = (1 + p1 + p12 ... p1a1) * (1 + p2 + p22 ... p2a2) * ............................................. (1 + pk + pk2 ... pkak) We can notice that individual terms of above formula are Geometric Progressions (GP). We can rewrite the formula as. Sum of divisors = (p1a1+1 - 1)/(p1 -1) * (p2a2+1 - 1)/(p2 -1) * .................................. (pkak+1 - 1)/(pk -1)65 Một giải pháp hiệu quả là sử dụng dưới đây công thức. & NBSP; Đặt P1, P2, PK PK là yếu tố chính của n. Đặt A1, A2, .. Ak là sức mạnh cao nhất của P1, P2, .. PK tương ứng chia n, tức là, chúng ta có thể viết n là n = (p1a1)* (p2a2)* Sum of divisors = (1 + p1 + p12 ... p1a1) * (1 + p2 + p22 ... p2a2) * ............................................. (1 + pk + pk2 ... pkak) We can notice that individual terms of above formula are Geometric Progressions (GP). We can rewrite the formula as. Sum of divisors = (p1a1+1 - 1)/(p1 -1) * (p2a2+1 - 1)/(p2 -1) * .................................. (pkak+1 - 1)/(pk -1)9 Làm thế nào để công thức trên hoạt động? & Nbsp; & nbsp; 5Vì vậy, nhiệm vụ làm giảm việc tìm kiếm tất cả các yếu tố chính và quyền hạn của họ. & Nbsp; & nbsp; 6Sum of divisors = (1 + p1 + p12 ... p1a1) * (1 + p2 + p22 ... p2a2) * ............................................. (1 + pk + pk2 ... pkak) We can notice that individual terms of above formula are Geometric Progressions (GP). We can rewrite the formula as. Sum of divisors = (p1a1+1 - 1)/(p1 -1) * (p2a2+1 - 1)/(p2 -1) * .................................. (pkak+1 - 1)/(pk -1)77
0Sum of divisors = (1 + p1 + p12 ... p1a1) * (1 + p2 + p22 ... p2a2) * ............................................. (1 + pk + pk2 ... pkak) We can notice that individual terms of above formula are Geometric Progressions (GP). We can rewrite the formula as. Sum of divisors = (p1a1+1 - 1)/(p1 -1) * (p2a2+1 - 1)/(p2 -1) * .................................. (pkak+1 - 1)/(pk -1)9 def isPerfect( n ): sum = 1 i = 2 while i * i <= n: if n % i == 0: sum = sum + i + n/i i += 1 return (True if sum == n and n!=1 else False) print("Below are all perfect numbers till 10000") n = 2 for n in range (10000): if isPerfect (n): print(n , " is a perfect number")1 Sum of divisors = (1 + p1 + p12 ... p1a1) * (1 + p2 + p22 ... p2a2) * ............................................. (1 + pk + pk2 ... pkak) We can notice that individual terms of above formula are Geometric Progressions (GP). We can rewrite the formula as. Sum of divisors = (p1a1+1 - 1)/(p1 -1) * (p2a2+1 - 1)/(p2 -1) * .................................. (pkak+1 - 1)/(pk -1)24def isPerfect( n ): sum = 1 i = 2 while i * i <= n: if n % i == 0: sum = sum + i + n/i i += 1 return (True if sum == n and n!=1 else False) print("Below are all perfect numbers till 10000") n = 2 for n in range (10000): if isPerfect (n): print(n , " is a perfect number")1 def isPerfect( n ): sum = 1 i = 2 while i * i <= n: if n % i == 0: sum = sum + i + n/i i += 1 return (True if sum == n and n!=1 else False) print("Below are all perfect numbers till 10000") n = 2 for n in range (10000): if isPerfect (n): print(n , " is a perfect number")4 6 1 Sum of divisors = (1 + p1 + p12 ... p1a1) * (1 + p2 + p22 ... p2a2) * ............................................. (1 + pk + pk2 ... pkak) We can notice that individual terms of above formula are Geometric Progressions (GP). We can rewrite the formula as. Sum of divisors = (p1a1+1 - 1)/(p1 -1) * (p2a2+1 - 1)/(p2 -1) * .................................. (pkak+1 - 1)/(pk -1)30 6Input : n = 30 Output : 72 Dividers sum 1 + 2 + 3 + 5 + 6 + 10 + 15 + 30 = 72 Input : n = 15 Output : 24 Dividers sum 1 + 3 + 5 + 15 = 246 Input : n = 30 Output : 72 Dividers sum 1 + 2 + 3 + 5 + 6 + 10 + 15 + 30 = 72 Input : n = 15 Output : 24 Dividers sum 1 + 3 + 5 + 15 = 247 1 Input : n = 30 Output : 72 Dividers sum 1 + 2 + 3 + 5 + 6 + 10 + 15 + 30 = 72 Input : n = 15 Output : 24 Dividers sum 1 + 3 + 5 + 15 = 249 720 721 724 1 Sum of divisors = (1 + p1 + p12 ... p1a1) * (1 + p2 + p22 ... p2a2) * ............................................. (1 + pk + pk2 ... pkak) We can notice that individual terms of above formula are Geometric Progressions (GP). We can rewrite the formula as. Sum of divisors = (p1a1+1 - 1)/(p1 -1) * (p2a2+1 - 1)/(p2 -1) * .................................. (pkak+1 - 1)/(pk -1)42 724 1 Sum of divisors = (1 + p1 + p12 ... p1a1) * (1 + p2 + p22 ... p2a2) * ............................................. (1 + pk + pk2 ... pkak) We can notice that individual terms of above formula are Geometric Progressions (GP). We can rewrite the formula as. Sum of divisors = (p1a1+1 - 1)/(p1 -1) * (p2a2+1 - 1)/(p2 -1) * .................................. (pkak+1 - 1)/(pk -1)45 6 5724 Sum of divisors = (1 + p1 + p12 ... p1a1) * (1 + p2 + p22 ... p2a2) * ............................................. (1 + pk + pk2 ... pkak) We can notice that individual terms of above formula are Geometric Progressions (GP). We can rewrite the formula as. Sum of divisors = (p1a1+1 - 1)/(p1 -1) * (p2a2+1 - 1)/(p2 -1) * .................................. (pkak+1 - 1)/(pk -1)47 Sum of divisors = (1 + p1 + p12 ... p1a1) * (1 + p2 + p22 ... p2a2) * ............................................. (1 + pk + pk2 ... pkak) We can notice that individual terms of above formula are Geometric Progressions (GP). We can rewrite the formula as. Sum of divisors = (p1a1+1 - 1)/(p1 -1) * (p2a2+1 - 1)/(p2 -1) * .................................. (pkak+1 - 1)/(pk -1)48 6 7 Sum of divisors = (1 + p1 + p12 ... p1a1) * (1 + p2 + p22 ... p2a2) * ............................................. (1 + pk + pk2 ... pkak) We can notice that individual terms of above formula are Geometric Progressions (GP). We can rewrite the formula as. Sum of divisors = (p1a1+1 - 1)/(p1 -1) * (p2a2+1 - 1)/(p2 -1) * .................................. (pkak+1 - 1)/(pk -1)63 724 5 6Input : n = 30 Output : 72 Dividers sum 1 + 2 + 3 + 5 + 6 + 10 + 15 + 30 = 72 Input : n = 15 Output : 24 Dividers sum 1 + 3 + 5 + 15 = 240 Sum of divisors = (1 + p1 + p12 ... p1a1) * (1 + p2 + p22 ... p2a2) * ............................................. (1 + pk + pk2 ... pkak) We can notice that individual terms of above formula are Geometric Progressions (GP). We can rewrite the formula as. Sum of divisors = (p1a1+1 - 1)/(p1 -1) * (p2a2+1 - 1)/(p2 -1) * .................................. (pkak+1 - 1)/(pk -1)68 729 1 Consider the number 18. Sum of factors = 1 + 2 + 3 + 6 + 9 + 18 Writing divisors as powers of prime factors. Sum of factors = (20)(30) + (21)(30) + (2^0)(31) + (21)(31) + (20)(3^2) + (2^1)(32) = (20)(30) + (2^0)(31) + (2^0)(32) + (21)(3^0) + (21)(31) + (21)(32) = (20)(30 + 31 + 32) + (21)(30 + 31 + 32) = (20 + 21)(30 + 31 + 32) If we take a closer look, we can notice that the above expression is in the form. (1 + p1) * (1 + p2 + p22) Where p1 = 2 and p2 = 3 and 18 = 213218 using 3using 8729 Sum of divisors = (1 + p1 + p12 ... p1a1) * (1 + p2 + p22 ... p2a2) * ............................................. (1 + pk + pk2 ... pkak) We can notice that individual terms of above formula are Geometric Progressions (GP). We can rewrite the formula as. Sum of divisors = (p1a1+1 - 1)/(p1 -1) * (p2a2+1 - 1)/(p2 -1) * .................................. (pkak+1 - 1)/(pk -1)47 05namespace 2using 4729 5Sum of divisors = (1 + p1 + p12 ... p1a1) * (1 + p2 + p22 ... p2a2) * ............................................. (1 + pk + pk2 ... pkak) We can notice that individual terms of above formula are Geometric Progressions (GP). We can rewrite the formula as. Sum of divisors = (p1a1+1 - 1)/(p1 -1) * (p2a2+1 - 1)/(p2 -1) * .................................. (pkak+1 - 1)/(pk -1)2 Sum of divisors = (1 + p1 + p12 ... p1a1) * (1 + p2 + p22 ... p2a2) * ............................................. (1 + pk + pk2 ... pkak) We can notice that individual terms of above formula are Geometric Progressions (GP). We can rewrite the formula as. Sum of divisors = (p1a1+1 - 1)/(p1 -1) * (p2a2+1 - 1)/(p2 -1) * .................................. (pkak+1 - 1)/(pk -1)50 Sum of divisors = (1 + p1 + p12 ... p1a1) * (1 + p2 + p22 ... p2a2) * ............................................. (1 + pk + pk2 ... pkak) We can notice that individual terms of above formula are Geometric Progressions (GP). We can rewrite the formula as. Sum of divisors = (p1a1+1 - 1)/(p1 -1) * (p2a2+1 - 1)/(p2 -1) * .................................. (pkak+1 - 1)/(pk -1)2 Sum of divisors = (1 + p1 + p12 ... p1a1) * (1 + p2 + p22 ... p2a2) * ............................................. (1 + pk + pk2 ... pkak) We can notice that individual terms of above formula are Geometric Progressions (GP). We can rewrite the formula as. Sum of divisors = (p1a1+1 - 1)/(p1 -1) * (p2a2+1 - 1)/(p2 -1) * .................................. (pkak+1 - 1)/(pk -1)52 Sum of divisors = (1 + p1 + p12 ... p1a1) * (1 + p2 + p22 ... p2a2) * ............................................. (1 + pk + pk2 ... pkak) We can notice that individual terms of above formula are Geometric Progressions (GP). We can rewrite the formula as. Sum of divisors = (p1a1+1 - 1)/(p1 -1) * (p2a2+1 - 1)/(p2 -1) * .................................. (pkak+1 - 1)/(pk -1)2 Sum of divisors = (1 + p1 + p12 ... p1a1) * (1 + p2 + p22 ... p2a2) * ............................................. (1 + pk + pk2 ... pkak) We can notice that individual terms of above formula are Geometric Progressions (GP). We can rewrite the formula as. Sum of divisors = (p1a1+1 - 1)/(p1 -1) * (p2a2+1 - 1)/(p2 -1) * .................................. (pkak+1 - 1)/(pk -1)54 729 Sum of divisors = (1 + p1 + p12 ... p1a1) * (1 + p2 + p22 ... p2a2) * ............................................. (1 + pk + pk2 ... pkak) We can notice that individual terms of above formula are Geometric Progressions (GP). We can rewrite the formula as. Sum of divisors = (p1a1+1 - 1)/(p1 -1) * (p2a2+1 - 1)/(p2 -1) * .................................. (pkak+1 - 1)/(pk -1)9 729 Sum of divisors = (1 + p1 + p12 ... p1a1) * (1 + p2 + p22 ... p2a2) * ............................................. (1 + pk + pk2 ... pkak) We can notice that individual terms of above formula are Geometric Progressions (GP). We can rewrite the formula as. Sum of divisors = (p1a1+1 - 1)/(p1 -1) * (p2a2+1 - 1)/(p2 -1) * .................................. (pkak+1 - 1)/(pk -1)58 724 Sum of divisors = (1 + p1 + p12 ... p1a1) * (1 + p2 + p22 ... p2a2) * ............................................. (1 + pk + pk2 ... pkak) We can notice that individual terms of above formula are Geometric Progressions (GP). We can rewrite the formula as. Sum of divisors = (p1a1+1 - 1)/(p1 -1) * (p2a2+1 - 1)/(p2 -1) * .................................. (pkak+1 - 1)/(pk -1)9 724 7 Consider the number 18. Sum of factors = 1 + 2 + 3 + 6 + 9 + 18 Writing divisors as powers of prime factors. Sum of factors = (20)(30) + (21)(30) + (2^0)(31) + (21)(31) + (20)(3^2) + (2^1)(32) = (20)(30) + (2^0)(31) + (2^0)(32) + (21)(3^0) + (21)(31) + (21)(32) = (20)(30 + 31 + 32) + (21)(30 + 31 + 32) = (20 + 21)(30 + 31 + 32) If we take a closer look, we can notice that the above expression is in the form. (1 + p1) * (1 + p2 + p22) Where p1 = 2 and p2 = 3 and 18 = 213242 namespace 9using 4729 Consider the number 18. Sum of factors = 1 + 2 + 3 + 6 + 9 + 18 Writing divisors as powers of prime factors. Sum of factors = (20)(30) + (21)(30) + (2^0)(31) + (21)(31) + (20)(3^2) + (2^1)(32) = (20)(30) + (2^0)(31) + (2^0)(32) + (21)(3^0) + (21)(31) + (21)(32) = (20)(30 + 31 + 32) + (21)(30 + 31 + 32) = (20 + 21)(30 + 31 + 32) If we take a closer look, we can notice that the above expression is in the form. (1 + p1) * (1 + p2 + p22) Where p1 = 2 and p2 = 3 and 18 = 213246 using 3 Consider the number 18. Sum of factors = 1 + 2 + 3 + 6 + 9 + 18 Writing divisors as powers of prime factors. Sum of factors = (20)(30) + (21)(30) + (2^0)(31) + (21)(31) + (20)(3^2) + (2^1)(32) = (20)(30) + (2^0)(31) + (2^0)(32) + (21)(3^0) + (21)(31) + (21)(32) = (20)(30 + 31 + 32) + (21)(30 + 31 + 32) = (20 + 21)(30 + 31 + 32) If we take a closer look, we can notice that the above expression is in the form. (1 + p1) * (1 + p2 + p22) Where p1 = 2 and p2 = 3 and 18 = 213248 724 Input : n = 30 Output : 72 Dividers sum 1 + 2 + 3 + 5 + 6 + 10 + 15 + 30 = 72 Input : n = 15 Output : 24 Dividers sum 1 + 3 + 5 + 15 = 240 Sum of divisors = (1 + p1 + p12 ... p1a1) * (1 + p2 + p22 ... p2a2) * ............................................. (1 + pk + pk2 ... pkak) We can notice that individual terms of above formula are Geometric Progressions (GP). We can rewrite the formula as. Sum of divisors = (p1a1+1 - 1)/(p1 -1) * (p2a2+1 - 1)/(p2 -1) * .................................. (pkak+1 - 1)/(pk -1)68 6Sum of divisors = (1 + p1 + p12 ... p1a1) * (1 + p2 + p22 ... p2a2) * ............................................. (1 + pk + pk2 ... pkak) We can notice that individual terms of above formula are Geometric Progressions (GP). We can rewrite the formula as. Sum of divisors = (p1a1+1 - 1)/(p1 -1) * (p2a2+1 - 1)/(p2 -1) * .................................. (pkak+1 - 1)/(pk -1)9 6 31 #include<bits/stdc++.h> 3 33 Consider the number 18. Sum of factors = 1 + 2 + 3 + 6 + 9 + 18 Writing divisors as powers of prime factors. Sum of factors = (20)(30) + (21)(30) + (2^0)(31) + (21)(31) + (20)(3^2) + (2^1)(32) = (20)(30) + (2^0)(31) + (2^0)(32) + (21)(3^0) + (21)(31) + (21)(32) = (20)(30 + 31 + 32) + (21)(30 + 31 + 32) = (20 + 21)(30 + 31 + 32) If we take a closer look, we can notice that the above expression is in the form. (1 + p1) * (1 + p2 + p22) Where p1 = 2 and p2 = 3 and 18 = 213258 6 5724 1 39 40using 8724 Consider the number 18. Sum of factors = 1 + 2 + 3 + 6 + 9 + 18 Writing divisors as powers of prime factors. Sum of factors = (20)(30) + (21)(30) + (2^0)(31) + (21)(31) + (20)(3^2) + (2^1)(32) = (20)(30) + (2^0)(31) + (2^0)(32) + (21)(3^0) + (21)(31) + (21)(32) = (20)(30 + 31 + 32) + (21)(30 + 31 + 32) = (20 + 21)(30 + 31 + 32) If we take a closer look, we can notice that the above expression is in the form. (1 + p1) * (1 + p2 + p22) Where p1 = 2 and p2 = 3 and 18 = 213267 6Sum of divisors = (1 + p1 + p12 ... p1a1) * (1 + p2 + p22 ... p2a2) * ............................................. (1 + pk + pk2 ... pkak) We can notice that individual terms of above formula are Geometric Progressions (GP). We can rewrite the formula as. Sum of divisors = (p1a1+1 - 1)/(p1 -1) * (p2a2+1 - 1)/(p2 -1) * .................................. (pkak+1 - 1)/(pk -1)9 Sum of divisors = (1 + p1 + p12 ... p1a1) * (1 + p2 + p22 ... p2a2) * ............................................. (1 + pk + pk2 ... pkak) We can notice that individual terms of above formula are Geometric Progressions (GP). We can rewrite the formula as. Sum of divisors = (p1a1+1 - 1)/(p1 -1) * (p2a2+1 - 1)/(p2 -1) * .................................. (pkak+1 - 1)/(pk -1)9 Python3728 Consider the number 18. Sum of factors = 1 + 2 + 3 + 6 + 9 + 18 Writing divisors as powers of prime factors. Sum of factors = (20)(30) + (21)(30) + (2^0)(31) + (21)(31) + (20)(3^2) + (2^1)(32) = (20)(30) + (2^0)(31) + (2^0)(32) + (21)(3^0) + (21)(31) + (21)(32) = (20)(30 + 31 + 32) + (21)(30 + 31 + 32) = (20 + 21)(30 + 31 + 32) If we take a closer look, we can notice that the above expression is in the form. (1 + p1) * (1 + p2 + p22) Where p1 = 2 and p2 = 3 and 18 = 213272 49 Consider the number 18. Sum of factors = 1 + 2 + 3 + 6 + 9 + 18 Writing divisors as powers of prime factors. Sum of factors = (20)(30) + (21)(30) + (2^0)(31) + (21)(31) + (20)(3^2) + (2^1)(32) = (20)(30) + (2^0)(31) + (2^0)(32) + (21)(3^0) + (21)(31) + (21)(32) = (20)(30 + 31 + 32) + (21)(30 + 31 + 32) = (20 + 21)(30 + 31 + 32) If we take a closer look, we can notice that the above expression is in the form. (1 + p1) * (1 + p2 + p22) Where p1 = 2 and p2 = 3 and 18 = 213274 6Consider the number 18. Sum of factors = 1 + 2 + 3 + 6 + 9 + 18 Writing divisors as powers of prime factors. Sum of factors = (20)(30) + (21)(30) + (2^0)(31) + (21)(31) + (20)(3^2) + (2^1)(32) = (20)(30) + (2^0)(31) + (2^0)(32) + (21)(3^0) + (21)(31) + (21)(32) = (20)(30 + 31 + 32) + (21)(30 + 31 + 32) = (20 + 21)(30 + 31 + 32) If we take a closer look, we can notice that the above expression is in the form. (1 + p1) * (1 + p2 + p22) Where p1 = 2 and p2 = 3 and 18 = 213276 54 using 3 6Input : n = 30 Output : 72 Dividers sum 1 + 2 + 3 + 5 + 6 + 10 + 15 + 30 = 72 Input : n = 15 Output : 24 Dividers sum 1 + 3 + 5 + 15 = 246 67 68724 Consider the number 18. Sum of factors = 1 + 2 + 3 + 6 + 9 + 18 Writing divisors as powers of prime factors. Sum of factors = (20)(30) + (21)(30) + (2^0)(31) + (21)(31) + (20)(3^2) + (2^1)(32) = (20)(30) + (2^0)(31) + (2^0)(32) + (21)(3^0) + (21)(31) + (21)(32) = (20)(30 + 31 + 32) + (21)(30 + 31 + 32) = (20 + 21)(30 + 31 + 32) If we take a closer look, we can notice that the above expression is in the form. (1 + p1) * (1 + p2 + p22) Where p1 = 2 and p2 = 3 and 18 = 213293 54 using 3
724 Consider the number 18. Sum of factors = 1 + 2 + 3 + 6 + 9 + 18 Writing divisors as powers of prime factors. Sum of factors = (20)(30) + (21)(30) + (2^0)(31) + (21)(31) + (20)(3^2) + (2^1)(32) = (20)(30) + (2^0)(31) + (2^0)(32) + (21)(3^0) + (21)(31) + (21)(32) = (20)(30 + 31 + 32) + (21)(30 + 31 + 32) = (20 + 21)(30 + 31 + 32) If we take a closer look, we can notice that the above expression is in the form. (1 + p1) * (1 + p2 + p22) Where p1 = 2 and p2 = 3 and 18 = 213297 54 using 3724 Sum of divisors = (1 + p1 + p12 ... p1a1) * (1 + p2 + p22 ... p2a2) * ............................................. (1 + pk + pk2 ... pkak) We can notice that individual terms of above formula are Geometric Progressions (GP). We can rewrite the formula as. Sum of divisors = (p1a1+1 - 1)/(p1 -1) * (p2a2+1 - 1)/(p2 -1) * .................................. (pkak+1 - 1)/(pk -1)47 Input : n = 30 Output : 72 Dividers sum 1 + 2 + 3 + 5 + 6 + 10 + 15 + 30 = 72 Input : n = 15 Output : 24 Dividers sum 1 + 3 + 5 + 15 = 2419 81 67 54__729 Input : n = 30 Output : 72 Dividers sum 1 + 2 + 3 + 5 + 6 + 10 + 15 + 30 = 72 Input : n = 15 Output : 24 Dividers sum 1 + 3 + 5 + 15 = 2419 54 Input : n = 30 Output : 72 Dividers sum 1 + 2 + 3 + 5 + 6 + 10 + 15 + 30 = 72 Input : n = 15 Output : 24 Dividers sum 1 + 3 + 5 + 15 = 2419 93 7214 729 Consider the number 18. Sum of factors = 1 + 2 + 3 + 6 + 9 + 18 Writing divisors as powers of prime factors. Sum of factors = (20)(30) + (21)(30) + (2^0)(31) + (21)(31) + (20)(3^2) + (2^1)(32) = (20)(30) + (2^0)(31) + (2^0)(32) + (21)(3^0) + (21)(31) + (21)(32) = (20)(30 + 31 + 32) + (21)(30 + 31 + 32) = (20 + 21)(30 + 31 + 32) If we take a closer look, we can notice that the above expression is in the form. (1 + p1) * (1 + p2 + p22) Where p1 = 2 and p2 = 3 and 18 = 213297 54 Consider the number 18. Sum of factors = 1 + 2 + 3 + 6 + 9 + 18 Writing divisors as powers of prime factors. Sum of factors = (20)(30) + (21)(30) + (2^0)(31) + (21)(31) + (20)(3^2) + (2^1)(32) = (20)(30) + (2^0)(31) + (2^0)(32) + (21)(3^0) + (21)(31) + (21)(32) = (20)(30 + 31 + 32) + (21)(30 + 31 + 32) = (20 + 21)(30 + 31 + 32) If we take a closer look, we can notice that the above expression is in the form. (1 + p1) * (1 + p2 + p22) Where p1 = 2 and p2 = 3 and 18 = 213297 7219 7214 729 Consider the number 18. Sum of factors = 1 + 2 + 3 + 6 + 9 + 18 Writing divisors as powers of prime factors. Sum of factors = (20)(30) + (21)(30) + (2^0)(31) + (21)(31) + (20)(3^2) + (2^1)(32) = (20)(30) + (2^0)(31) + (2^0)(32) + (21)(3^0) + (21)(31) + (21)(32) = (20)(30 + 31 + 32) + (21)(30 + 31 + 32) = (20 + 21)(30 + 31 + 32) If we take a closer look, we can notice that the above expression is in the form. (1 + p1) * (1 + p2 + p22) Where p1 = 2 and p2 = 3 and 18 = 213293 75 54 7225 724 Consider the number 18. Sum of factors = 1 + 2 + 3 + 6 + 9 + 18 Writing divisors as powers of prime factors. Sum of factors = (20)(30) + (21)(30) + (2^0)(31) + (21)(31) + (20)(3^2) + (2^1)(32) = (20)(30) + (2^0)(31) + (2^0)(32) + (21)(3^0) + (21)(31) + (21)(32) = (20)(30 + 31 + 32) + (21)(30 + 31 + 32) = (20 + 21)(30 + 31 + 32) If we take a closer look, we can notice that the above expression is in the form. (1 + p1) * (1 + p2 + p22) Where p1 = 2 and p2 = 3 and 18 = 213276 54 Consider the number 18. Sum of factors = 1 + 2 + 3 + 6 + 9 + 18 Writing divisors as powers of prime factors. Sum of factors = (20)(30) + (21)(30) + (2^0)(31) + (21)(31) + (20)(3^2) + (2^1)(32) = (20)(30) + (2^0)(31) + (2^0)(32) + (21)(3^0) + (21)(31) + (21)(32) = (20)(30 + 31 + 32) + (21)(30 + 31 + 32) = (20 + 21)(30 + 31 + 32) If we take a closer look, we can notice that the above expression is in the form. (1 + p1) * (1 + p2 + p22) Where p1 = 2 and p2 = 3 and 18 = 213276 7219 7231 6 7 7234 namespace 9Input : n = 30 Output : 72 Dividers sum 1 + 2 + 3 + 5 + 6 + 10 + 15 + 30 = 72 Input : n = 15 Output : 24 Dividers sum 1 + 3 + 5 + 15 = 2403 724 Consider the number 18. Sum of factors = 1 + 2 + 3 + 6 + 9 + 18 Writing divisors as powers of prime factors. Sum of factors = (20)(30) + (21)(30) + (2^0)(31) + (21)(31) + (20)(3^2) + (2^1)(32) = (20)(30) + (2^0)(31) + (2^0)(32) + (21)(3^0) + (21)(31) + (21)(32) = (20)(30 + 31 + 32) + (21)(30 + 31 + 32) = (20 + 21)(30 + 31 + 32) If we take a closer look, we can notice that the above expression is in the form. (1 + p1) * (1 + p2 + p22) Where p1 = 2 and p2 = 3 and 18 = 213276 54 Consider the number 18. Sum of factors = 1 + 2 + 3 + 6 + 9 + 18 Writing divisors as powers of prime factors. Sum of factors = (20)(30) + (21)(30) + (2^0)(31) + (21)(31) + (20)(3^2) + (2^1)(32) = (20)(30) + (2^0)(31) + (2^0)(32) + (21)(3^0) + (21)(31) + (21)(32) = (20)(30 + 31 + 32) + (21)(30 + 31 + 32) = (20 + 21)(30 + 31 + 32) If we take a closer look, we can notice that the above expression is in the form. (1 + p1) * (1 + p2 + p22) Where p1 = 2 and p2 = 3 and 18 = 213276 7219 Input : n = 30 Output : 72 Dividers sum 1 + 2 + 3 + 5 + 6 + 10 + 15 + 30 = 72 Input : n = 15 Output : 24 Dividers sum 1 + 3 + 5 + 15 = 247 using 3 6Input : n = 30 Output : 72 Dividers sum 1 + 2 + 3 + 5 + 6 + 10 + 15 + 30 = 72 Input : n = 15 Output : 24 Dividers sum 1 + 3 + 5 + 15 = 240 Sum of divisors = (1 + p1 + p12 ... p1a1) * (1 + p2 + p22 ... p2a2) * ............................................. (1 + pk + pk2 ... pkak) We can notice that individual terms of above formula are Geometric Progressions (GP). We can rewrite the formula as. Sum of divisors = (p1a1+1 - 1)/(p1 -1) * (p2a2+1 - 1)/(p2 -1) * .................................. (pkak+1 - 1)/(pk -1)68 7249 54 Sum of divisors = (1 + p1 + p12 ... p1a1) * (1 + p2 + p22 ... p2a2) * ............................................. (1 + pk + pk2 ... pkak) We can notice that individual terms of above formula are Geometric Progressions (GP). We can rewrite the formula as. Sum of divisors = (p1a1+1 - 1)/(p1 -1) * (p2a2+1 - 1)/(p2 -1) * .................................. (pkak+1 - 1)/(pk -1)24 40using 4Input : n = 30 Output : 72 Dividers sum 1 + 2 + 3 + 5 + 6 + 10 + 15 + 30 = 72 Input : n = 15 Output : 24 Dividers sum 1 + 3 + 5 + 15 = 2426 Input : n = 30 Output : 72 Dividers sum 1 + 2 + 3 + 5 + 6 + 10 + 15 + 30 = 72 Input : n = 15 Output : 24 Dividers sum 1 + 3 + 5 + 15 = 247 7256 7257 7249 using 4C#
Input : n = 30 Output : 72 Dividers sum 1 + 2 + 3 + 5 + 6 + 10 + 15 + 30 = 72 Input : n = 15 Output : 24 Dividers sum 1 + 3 + 5 + 15 = 2429 31 #include<bits/stdc++.h> 0 #include<bits/stdc++.h> 1 6#include<bits/stdc++.h> 3 1 Sum of divisors = (1 + p1 + p12 ... p1a1) * (1 + p2 + p22 ... p2a2) * ............................................. (1 + pk + pk2 ... pkak) We can notice that individual terms of above formula are Geometric Progressions (GP). We can rewrite the formula as. Sum of divisors = (p1a1+1 - 1)/(p1 -1) * (p2a2+1 - 1)/(p2 -1) * .................................. (pkak+1 - 1)/(pk -1)24 1 4 6 5724 1 Sum of divisors = (1 + p1 + p12 ... p1a1) * (1 + p2 + p22 ... p2a2) * ............................................. (1 + pk + pk2 ... pkak) We can notice that individual terms of above formula are Geometric Progressions (GP). We can rewrite the formula as. Sum of divisors = (p1a1+1 - 1)/(p1 -1) * (p2a2+1 - 1)/(p2 -1) * .................................. (pkak+1 - 1)/(pk -1)30 724 Input : n = 30 Output : 72 Dividers sum 1 + 2 + 3 + 5 + 6 + 10 + 15 + 30 = 72 Input : n = 15 Output : 24 Dividers sum 1 + 3 + 5 + 15 = 246 Input : n = 30 Output : 72 Dividers sum 1 + 2 + 3 + 5 + 6 + 10 + 15 + 30 = 72 Input : n = 15 Output : 24 Dividers sum 1 + 3 + 5 + 15 = 247 1 Input : n = 30 Output : 72 Dividers sum 1 + 2 + 3 + 5 + 6 + 10 + 15 + 30 = 72 Input : n = 15 Output : 24 Dividers sum 1 + 3 + 5 + 15 = 2453 724 5729 1 Sum of divisors = (1 + p1 + p12 ... p1a1) * (1 + p2 + p22 ... p2a2) * ............................................. (1 + pk + pk2 ... pkak) We can notice that individual terms of above formula are Geometric Progressions (GP). We can rewrite the formula as. Sum of divisors = (p1a1+1 - 1)/(p1 -1) * (p2a2+1 - 1)/(p2 -1) * .................................. (pkak+1 - 1)/(pk -1)42 729 1 Sum of divisors = (1 + p1 + p12 ... p1a1) * (1 + p2 + p22 ... p2a2) * ............................................. (1 + pk + pk2 ... pkak) We can notice that individual terms of above formula are Geometric Progressions (GP). We can rewrite the formula as. Sum of divisors = (p1a1+1 - 1)/(p1 -1) * (p2a2+1 - 1)/(p2 -1) * .................................. (pkak+1 - 1)/(pk -1)45 729 Sum of divisors = (1 + p1 + p12 ... p1a1) * (1 + p2 + p22 ... p2a2) * ............................................. (1 + pk + pk2 ... pkak) We can notice that individual terms of above formula are Geometric Progressions (GP). We can rewrite the formula as. Sum of divisors = (p1a1+1 - 1)/(p1 -1) * (p2a2+1 - 1)/(p2 -1) * .................................. (pkak+1 - 1)/(pk -1)47 726 729 5Sum of divisors = (1 + p1 + p12 ... p1a1) * (1 + p2 + p22 ... p2a2) * ............................................. (1 + pk + pk2 ... pkak) We can notice that individual terms of above formula are Geometric Progressions (GP). We can rewrite the formula as. Sum of divisors = (p1a1+1 - 1)/(p1 -1) * (p2a2+1 - 1)/(p2 -1) * .................................. (pkak+1 - 1)/(pk -1)2 Sum of divisors = (1 + p1 + p12 ... p1a1) * (1 + p2 + p22 ... p2a2) * ............................................. (1 + pk + pk2 ... pkak) We can notice that individual terms of above formula are Geometric Progressions (GP). We can rewrite the formula as. Sum of divisors = (p1a1+1 - 1)/(p1 -1) * (p2a2+1 - 1)/(p2 -1) * .................................. (pkak+1 - 1)/(pk -1)50 Sum of divisors = (1 + p1 + p12 ... p1a1) * (1 + p2 + p22 ... p2a2) * ............................................. (1 + pk + pk2 ... pkak) We can notice that individual terms of above formula are Geometric Progressions (GP). We can rewrite the formula as. Sum of divisors = (p1a1+1 - 1)/(p1 -1) * (p2a2+1 - 1)/(p2 -1) * .................................. (pkak+1 - 1)/(pk -1)2 Sum of divisors = (1 + p1 + p12 ... p1a1) * (1 + p2 + p22 ... p2a2) * ............................................. (1 + pk + pk2 ... pkak) We can notice that individual terms of above formula are Geometric Progressions (GP). We can rewrite the formula as. Sum of divisors = (p1a1+1 - 1)/(p1 -1) * (p2a2+1 - 1)/(p2 -1) * .................................. (pkak+1 - 1)/(pk -1)52 Sum of divisors = (1 + p1 + p12 ... p1a1) * (1 + p2 + p22 ... p2a2) * ............................................. (1 + pk + pk2 ... pkak) We can notice that individual terms of above formula are Geometric Progressions (GP). We can rewrite the formula as. Sum of divisors = (p1a1+1 - 1)/(p1 -1) * (p2a2+1 - 1)/(p2 -1) * .................................. (pkak+1 - 1)/(pk -1)2 Sum of divisors = (1 + p1 + p12 ... p1a1) * (1 + p2 + p22 ... p2a2) * ............................................. (1 + pk + pk2 ... pkak) We can notice that individual terms of above formula are Geometric Progressions (GP). We can rewrite the formula as. Sum of divisors = (p1a1+1 - 1)/(p1 -1) * (p2a2+1 - 1)/(p2 -1) * .................................. (pkak+1 - 1)/(pk -1)54 729 Sum of divisors = (1 + p1 + p12 ... p1a1) * (1 + p2 + p22 ... p2a2) * ............................................. (1 + pk + pk2 ... pkak) We can notice that individual terms of above formula are Geometric Progressions (GP). We can rewrite the formula as. Sum of divisors = (p1a1+1 - 1)/(p1 -1) * (p2a2+1 - 1)/(p2 -1) * .................................. (pkak+1 - 1)/(pk -1)9 729 Sum of divisors = (1 + p1 + p12 ... p1a1) * (1 + p2 + p22 ... p2a2) * ............................................. (1 + pk + pk2 ... pkak) We can notice that individual terms of above formula are Geometric Progressions (GP). We can rewrite the formula as. Sum of divisors = (p1a1+1 - 1)/(p1 -1) * (p2a2+1 - 1)/(p2 -1) * .................................. (pkak+1 - 1)/(pk -1)58 724 Sum of divisors = (1 + p1 + p12 ... p1a1) * (1 + p2 + p22 ... p2a2) * ............................................. (1 + pk + pk2 ... pkak) We can notice that individual terms of above formula are Geometric Progressions (GP). We can rewrite the formula as. Sum of divisors = (p1a1+1 - 1)/(p1 -1) * (p2a2+1 - 1)/(p2 -1) * .................................. (pkak+1 - 1)/(pk -1)9 724 7 #include<bits/stdc++.h> 08729 Sum of divisors = (1 + p1 + p12 ... p1a1) * (1 + p2 + p22 ... p2a2) * ............................................. (1 + pk + pk2 ... pkak) We can notice that individual terms of above formula are Geometric Progressions (GP). We can rewrite the formula as. Sum of divisors = (p1a1+1 - 1)/(p1 -1) * (p2a2+1 - 1)/(p2 -1) * .................................. (pkak+1 - 1)/(pk -1)65 724 Input : n = 30 Output : 72 Dividers sum 1 + 2 + 3 + 5 + 6 + 10 + 15 + 30 = 72 Input : n = 15 Output : 24 Dividers sum 1 + 3 + 5 + 15 = 240 Sum of divisors = (1 + p1 + p12 ... p1a1) * (1 + p2 + p22 ... p2a2) * ............................................. (1 + pk + pk2 ... pkak) We can notice that individual terms of above formula are Geometric Progressions (GP). We can rewrite the formula as. Sum of divisors = (p1a1+1 - 1)/(p1 -1) * (p2a2+1 - 1)/(p2 -1) * .................................. (pkak+1 - 1)/(pk -1)68 6Sum of divisors = (1 + p1 + p12 ... p1a1) * (1 + p2 + p22 ... p2a2) * ............................................. (1 + pk + pk2 ... pkak) We can notice that individual terms of above formula are Geometric Progressions (GP). We can rewrite the formula as. Sum of divisors = (p1a1+1 - 1)/(p1 -1) * (p2a2+1 - 1)/(p2 -1) * .................................. (pkak+1 - 1)/(pk -1)9 6 31 #include<bits/stdc++.h> 3 33 Consider the number 18. Sum of factors = 1 + 2 + 3 + 6 + 9 + 18 Writing divisors as powers of prime factors. Sum of factors = (20)(30) + (21)(30) + (2^0)(31) + (21)(31) + (20)(3^2) + (2^1)(32) = (20)(30) + (2^0)(31) + (2^0)(32) + (21)(3^0) + (21)(31) + (21)(32) = (20)(30 + 31 + 32) + (21)(30 + 31 + 32) = (20 + 21)(30 + 31 + 32) If we take a closer look, we can notice that the above expression is in the form. (1 + p1) * (1 + p2 + p22) Where p1 = 2 and p2 = 3 and 18 = 213258 6 5724 1 39 40using 8724 #include<bits/stdc++.h> 27 6Sum of divisors = (1 + p1 + p12 ... p1a1) * (1 + p2 + p22 ... p2a2) * ............................................. (1 + pk + pk2 ... pkak) We can notice that individual terms of above formula are Geometric Progressions (GP). We can rewrite the formula as. Sum of divisors = (p1a1+1 - 1)/(p1 -1) * (p2a2+1 - 1)/(p2 -1) * .................................. (pkak+1 - 1)/(pk -1)9 Sum of divisors = (1 + p1 + p12 ... p1a1) * (1 + p2 + p22 ... p2a2) * ............................................. (1 + pk + pk2 ... pkak) We can notice that individual terms of above formula are Geometric Progressions (GP). We can rewrite the formula as. Sum of divisors = (p1a1+1 - 1)/(p1 -1) * (p2a2+1 - 1)/(p2 -1) * .................................. (pkak+1 - 1)/(pk -1)9 728 Consider the number 18. Sum of factors = 1 + 2 + 3 + 6 + 9 + 18 Writing divisors as powers of prime factors. Sum of factors = (20)(30) + (21)(30) + (2^0)(31) + (21)(31) + (20)(3^2) + (2^1)(32) = (20)(30) + (2^0)(31) + (2^0)(32) + (21)(3^0) + (21)(31) + (21)(32) = (20)(30 + 31 + 32) + (21)(30 + 31 + 32) = (20 + 21)(30 + 31 + 32) If we take a closer look, we can notice that the above expression is in the form. (1 + p1) * (1 + p2 + p22) Where p1 = 2 and p2 = 3 and 18 = 213272Input : n = 30 Output : 72 Dividers sum 1 + 2 + 3 + 5 + 6 + 10 + 15 + 30 = 72 Input : n = 15 Output : 24 Dividers sum 1 + 3 + 5 + 15 = 2494 49 Consider the number 18. Sum of factors = 1 + 2 + 3 + 6 + 9 + 18 Writing divisors as powers of prime factors. Sum of factors = (20)(30) + (21)(30) + (2^0)(31) + (21)(31) + (20)(3^2) + (2^1)(32) = (20)(30) + (2^0)(31) + (2^0)(32) + (21)(3^0) + (21)(31) + (21)(32) = (20)(30 + 31 + 32) + (21)(30 + 31 + 32) = (20 + 21)(30 + 31 + 32) If we take a closer look, we can notice that the above expression is in the form. (1 + p1) * (1 + p2 + p22) Where p1 = 2 and p2 = 3 and 18 = 213274 5 6Consider the number 18. Sum of factors = 1 + 2 + 3 + 6 + 9 + 18 Writing divisors as powers of prime factors. Sum of factors = (20)(30) + (21)(30) + (2^0)(31) + (21)(31) + (20)(3^2) + (2^1)(32) = (20)(30) + (2^0)(31) + (2^0)(32) + (21)(3^0) + (21)(31) + (21)(32) = (20)(30 + 31 + 32) + (21)(30 + 31 + 32) = (20 + 21)(30 + 31 + 32) If we take a closer look, we can notice that the above expression is in the form. (1 + p1) * (1 + p2 + p22) Where p1 = 2 and p2 = 3 and 18 = 213276 54 using 3 6Input : n = 30 Output : 72 Dividers sum 1 + 2 + 3 + 5 + 6 + 10 + 15 + 30 = 72 Input : n = 15 Output : 24 Dividers sum 1 + 3 + 5 + 15 = 246 67 68 6 5724 Consider the number 18. Sum of factors = 1 + 2 + 3 + 6 + 9 + 18 Writing divisors as powers of prime factors. Sum of factors = (20)(30) + (21)(30) + (2^0)(31) + (21)(31) + (20)(3^2) + (2^1)(32) = (20)(30) + (2^0)(31) + (2^0)(32) + (21)(3^0) + (21)(31) + (21)(32) = (20)(30 + 31 + 32) + (21)(30 + 31 + 32) = (20 + 21)(30 + 31 + 32) If we take a closer look, we can notice that the above expression is in the form. (1 + p1) * (1 + p2 + p22) Where p1 = 2 and p2 = 3 and 18 = 213293 54 using 3724 Consider the number 18. Sum of factors = 1 + 2 + 3 + 6 + 9 + 18 Writing divisors as powers of prime factors. Sum of factors = (20)(30) + (21)(30) + (2^0)(31) + (21)(31) + (20)(3^2) + (2^1)(32) = (20)(30) + (2^0)(31) + (2^0)(32) + (21)(3^0) + (21)(31) + (21)(32) = (20)(30 + 31 + 32) + (21)(30 + 31 + 32) = (20 + 21)(30 + 31 + 32) If we take a closer look, we can notice that the above expression is in the form. (1 + p1) * (1 + p2 + p22) Where p1 = 2 and p2 = 3 and 18 = 213297 54 using 3724 Sum of divisors = (1 + p1 + p12 ... p1a1) * (1 + p2 + p22 ... p2a2) * ............................................. (1 + pk + pk2 ... pkak) We can notice that individual terms of above formula are Geometric Progressions (GP). We can rewrite the formula as. Sum of divisors = (p1a1+1 - 1)/(p1 -1) * (p2a2+1 - 1)/(p2 -1) * .................................. (pkak+1 - 1)/(pk -1)47 Input : n = 30 Output : 72 Dividers sum 1 + 2 + 3 + 5 + 6 + 10 + 15 + 30 = 72 Input : n = 15 Output : 24 Dividers sum 1 + 3 + 5 + 15 = 2419 81 67 54__724 5729 Input : n = 30 Output : 72 Dividers sum 1 + 2 + 3 + 5 + 6 + 10 + 15 + 30 = 72 Input : n = 15 Output : 24 Dividers sum 1 + 3 + 5 + 15 = 2419 54 Input : n = 30 Output : 72 Dividers sum 1 + 2 + 3 + 5 + 6 + 10 + 15 + 30 = 72 Input : n = 15 Output : 24 Dividers sum 1 + 3 + 5 + 15 = 2419 93 7214 729 Consider the number 18. Sum of factors = 1 + 2 + 3 + 6 + 9 + 18 Writing divisors as powers of prime factors. Sum of factors = (20)(30) + (21)(30) + (2^0)(31) + (21)(31) + (20)(3^2) + (2^1)(32) = (20)(30) + (2^0)(31) + (2^0)(32) + (21)(3^0) + (21)(31) + (21)(32) = (20)(30 + 31 + 32) + (21)(30 + 31 + 32) = (20 + 21)(30 + 31 + 32) If we take a closer look, we can notice that the above expression is in the form. (1 + p1) * (1 + p2 + p22) Where p1 = 2 and p2 = 3 and 18 = 213297 54 Consider the number 18. Sum of factors = 1 + 2 + 3 + 6 + 9 + 18 Writing divisors as powers of prime factors. Sum of factors = (20)(30) + (21)(30) + (2^0)(31) + (21)(31) + (20)(3^2) + (2^1)(32) = (20)(30) + (2^0)(31) + (2^0)(32) + (21)(3^0) + (21)(31) + (21)(32) = (20)(30 + 31 + 32) + (21)(30 + 31 + 32) = (20 + 21)(30 + 31 + 32) If we take a closer look, we can notice that the above expression is in the form. (1 + p1) * (1 + p2 + p22) Where p1 = 2 and p2 = 3 and 18 = 213297 7219 7214 729 Consider the number 18. Sum of factors = 1 + 2 + 3 + 6 + 9 + 18 Writing divisors as powers of prime factors. Sum of factors = (20)(30) + (21)(30) + (2^0)(31) + (21)(31) + (20)(3^2) + (2^1)(32) = (20)(30) + (2^0)(31) + (2^0)(32) + (21)(3^0) + (21)(31) + (21)(32) = (20)(30 + 31 + 32) + (21)(30 + 31 + 32) = (20 + 21)(30 + 31 + 32) If we take a closer look, we can notice that the above expression is in the form. (1 + p1) * (1 + p2 + p22) Where p1 = 2 and p2 = 3 and 18 = 213293 75 54 7225 724 Sum of divisors = (1 + p1 + p12 ... p1a1) * (1 + p2 + p22 ... p2a2) * ............................................. (1 + pk + pk2 ... pkak) We can notice that individual terms of above formula are Geometric Progressions (GP). We can rewrite the formula as. Sum of divisors = (p1a1+1 - 1)/(p1 -1) * (p2a2+1 - 1)/(p2 -1) * .................................. (pkak+1 - 1)/(pk -1)9 724 Consider the number 18. Sum of factors = 1 + 2 + 3 + 6 + 9 + 18 Writing divisors as powers of prime factors. Sum of factors = (20)(30) + (21)(30) + (2^0)(31) + (21)(31) + (20)(3^2) + (2^1)(32) = (20)(30) + (2^0)(31) + (2^0)(32) + (21)(3^0) + (21)(31) + (21)(32) = (20)(30 + 31 + 32) + (21)(30 + 31 + 32) = (20 + 21)(30 + 31 + 32) If we take a closer look, we can notice that the above expression is in the form. (1 + p1) * (1 + p2 + p22) Where p1 = 2 and p2 = 3 and 18 = 213276 54 Consider the number 18. Sum of factors = 1 + 2 + 3 + 6 + 9 + 18 Writing divisors as powers of prime factors. Sum of factors = (20)(30) + (21)(30) + (2^0)(31) + (21)(31) + (20)(3^2) + (2^1)(32) = (20)(30) + (2^0)(31) + (2^0)(32) + (21)(3^0) + (21)(31) + (21)(32) = (20)(30 + 31 + 32) + (21)(30 + 31 + 32) = (20 + 21)(30 + 31 + 32) If we take a closer look, we can notice that the above expression is in the form. (1 + p1) * (1 + p2 + p22) Where p1 = 2 and p2 = 3 and 18 = 213276 7219 7231 6Sum of divisors = (1 + p1 + p12 ... p1a1) * (1 + p2 + p22 ... p2a2) * ............................................. (1 + pk + pk2 ... pkak) We can notice that individual terms of above formula are Geometric Progressions (GP). We can rewrite the formula as. Sum of divisors = (p1a1+1 - 1)/(p1 -1) * (p2a2+1 - 1)/(p2 -1) * .................................. (pkak+1 - 1)/(pk -1)9 6 7 7234 namespace 9Input : n = 30 Output : 72 Dividers sum 1 + 2 + 3 + 5 + 6 + 10 + 15 + 30 = 72 Input : n = 15 Output : 24 Dividers sum 1 + 3 + 5 + 15 = 2403 724 Consider the number 18. Sum of factors = 1 + 2 + 3 + 6 + 9 + 18 Writing divisors as powers of prime factors. Sum of factors = (20)(30) + (21)(30) + (2^0)(31) + (21)(31) + (20)(3^2) + (2^1)(32) = (20)(30) + (2^0)(31) + (2^0)(32) + (21)(3^0) + (21)(31) + (21)(32) = (20)(30 + 31 + 32) + (21)(30 + 31 + 32) = (20 + 21)(30 + 31 + 32) If we take a closer look, we can notice that the above expression is in the form. (1 + p1) * (1 + p2 + p22) Where p1 = 2 and p2 = 3 and 18 = 213276 54 Consider the number 18. Sum of factors = 1 + 2 + 3 + 6 + 9 + 18 Writing divisors as powers of prime factors. Sum of factors = (20)(30) + (21)(30) + (2^0)(31) + (21)(31) + (20)(3^2) + (2^1)(32) = (20)(30) + (2^0)(31) + (2^0)(32) + (21)(3^0) + (21)(31) + (21)(32) = (20)(30 + 31 + 32) + (21)(30 + 31 + 32) = (20 + 21)(30 + 31 + 32) If we take a closer look, we can notice that the above expression is in the form. (1 + p1) * (1 + p2 + p22) Where p1 = 2 and p2 = 3 and 18 = 213276 7219 Input : n = 30 Output : 72 Dividers sum 1 + 2 + 3 + 5 + 6 + 10 + 15 + 30 = 72 Input : n = 15 Output : 24 Dividers sum 1 + 3 + 5 + 15 = 247 using 3 6Input : n = 30 Output : 72 Dividers sum 1 + 2 + 3 + 5 + 6 + 10 + 15 + 30 = 72 Input : n = 15 Output : 24 Dividers sum 1 + 3 + 5 + 15 = 240 Sum of divisors = (1 + p1 + p12 ... p1a1) * (1 + p2 + p22 ... p2a2) * ............................................. (1 + pk + pk2 ... pkak) We can notice that individual terms of above formula are Geometric Progressions (GP). We can rewrite the formula as. Sum of divisors = (p1a1+1 - 1)/(p1 -1) * (p2a2+1 - 1)/(p2 -1) * .................................. (pkak+1 - 1)/(pk -1)68 Sum of divisors = (1 + p1 + p12 ... p1a1) * (1 + p2 + p22 ... p2a2) * ............................................. (1 + pk + pk2 ... pkak) We can notice that individual terms of above formula are Geometric Progressions (GP). We can rewrite the formula as. Sum of divisors = (p1a1+1 - 1)/(p1 -1) * (p2a2+1 - 1)/(p2 -1) * .................................. (pkak+1 - 1)/(pk -1)9 7249 54 Sum of divisors = (1 + p1 + p12 ... p1a1) * (1 + p2 + p22 ... p2a2) * ............................................. (1 + pk + pk2 ... pkak) We can notice that individual terms of above formula are Geometric Progressions (GP). We can rewrite the formula as. Sum of divisors = (p1a1+1 - 1)/(p1 -1) * (p2a2+1 - 1)/(p2 -1) * .................................. (pkak+1 - 1)/(pk -1)24 40using 4Input : n = 30 Output : 72 Dividers sum 1 + 2 + 3 + 5 + 6 + 10 + 15 + 30 = 72 Input : n = 15 Output : 24 Dividers sum 1 + 3 + 5 + 15 = 2426 Input : n = 30 Output : 72 Dividers sum 1 + 2 + 3 + 5 + 6 + 10 + 15 + 30 = 72 Input : n = 15 Output : 24 Dividers sum 1 + 3 + 5 + 15 = 247 7256 7257 7249 using 47276 using Input : n = 30 Output : 72 Dividers sum 1 + 2 + 3 + 5 + 6 + 10 + 15 + 30 = 72 Input : n = 15 Output : 24 Dividers sum 1 + 3 + 5 + 15 = 24297277 31 #include<bits/stdc++.h> 0 #include<bits/stdc++.h> 1 5 6using 21 6#include<bits/stdc++.h> 3 1 Sum of divisors = (1 + p1 + p12 ... p1a1) * (1 + p2 + p22 ... p2a2) * ............................................. (1 + pk + pk2 ... pkak) We can notice that individual terms of above formula are Geometric Progressions (GP). We can rewrite the formula as. Sum of divisors = (p1a1+1 - 1)/(p1 -1) * (p2a2+1 - 1)/(p2 -1) * .................................. (pkak+1 - 1)/(pk -1)24 1 4 6 5724 using 28724 using 30724 1 Sum of divisors = (1 + p1 + p12 ... p1a1) * (1 + p2 + p22 ... p2a2) * ............................................. (1 + pk + pk2 ... pkak) We can notice that individual terms of above formula are Geometric Progressions (GP). We can rewrite the formula as. Sum of divisors = (p1a1+1 - 1)/(p1 -1) * (p2a2+1 - 1)/(p2 -1) * .................................. (pkak+1 - 1)/(pk -1)30 724 5729 Sum of divisors = (1 + p1 + p12 ... p1a1) * (1 + p2 + p22 ... p2a2) * ............................................. (1 + pk + pk2 ... pkak) We can notice that individual terms of above formula are Geometric Progressions (GP). We can rewrite the formula as. Sum of divisors = (p1a1+1 - 1)/(p1 -1) * (p2a2+1 - 1)/(p2 -1) * .................................. (pkak+1 - 1)/(pk -1)50 729 Sum of divisors = (1 + p1 + p12 ... p1a1) * (1 + p2 + p22 ... p2a2) * ............................................. (1 + pk + pk2 ... pkak) We can notice that individual terms of above formula are Geometric Progressions (GP). We can rewrite the formula as. Sum of divisors = (p1a1+1 - 1)/(p1 -1) * (p2a2+1 - 1)/(p2 -1) * .................................. (pkak+1 - 1)/(pk -1)52 729 Sum of divisors = (1 + p1 + p12 ... p1a1) * (1 + p2 + p22 ... p2a2) * ............................................. (1 + pk + pk2 ... pkak) We can notice that individual terms of above formula are Geometric Progressions (GP). We can rewrite the formula as. Sum of divisors = (p1a1+1 - 1)/(p1 -1) * (p2a2+1 - 1)/(p2 -1) * .................................. (pkak+1 - 1)/(pk -1)54 724 Sum of divisors = (1 + p1 + p12 ... p1a1) * (1 + p2 + p22 ... p2a2) * ............................................. (1 + pk + pk2 ... pkak) We can notice that individual terms of above formula are Geometric Progressions (GP). We can rewrite the formula as. Sum of divisors = (p1a1+1 - 1)/(p1 -1) * (p2a2+1 - 1)/(p2 -1) * .................................. (pkak+1 - 1)/(pk -1)9 724 Sum of divisors = (1 + p1 + p12 ... p1a1) * (1 + p2 + p22 ... p2a2) * ............................................. (1 + pk + pk2 ... pkak) We can notice that individual terms of above formula are Geometric Progressions (GP). We can rewrite the formula as. Sum of divisors = (p1a1+1 - 1)/(p1 -1) * (p2a2+1 - 1)/(p2 -1) * .................................. (pkak+1 - 1)/(pk -1)58 6Sum of divisors = (1 + p1 + p12 ... p1a1) * (1 + p2 + p22 ... p2a2) * ............................................. (1 + pk + pk2 ... pkak) We can notice that individual terms of above formula are Geometric Progressions (GP). We can rewrite the formula as. Sum of divisors = (p1a1+1 - 1)/(p1 -1) * (p2a2+1 - 1)/(p2 -1) * .................................. (pkak+1 - 1)/(pk -1)9 724 Input : n = 30 Output : 72 Dividers sum 1 + 2 + 3 + 5 + 6 + 10 + 15 + 30 = 72 Input : n = 15 Output : 24 Dividers sum 1 + 3 + 5 + 15 = 246 Input : n = 30 Output : 72 Dividers sum 1 + 2 + 3 + 5 + 6 + 10 + 15 + 30 = 72 Input : n = 15 Output : 24 Dividers sum 1 + 3 + 5 + 15 = 247 1 Input : n = 30 Output : 72 Dividers sum 1 + 2 + 3 + 5 + 6 + 10 + 15 + 30 = 72 Input : n = 15 Output : 24 Dividers sum 1 + 3 + 5 + 15 = 2453 724 Sum of divisors = (1 + p1 + p12 ... p1a1) * (1 + p2 + p22 ... p2a2) * ............................................. (1 + pk + pk2 ... pkak) We can notice that individual terms of above formula are Geometric Progressions (GP). We can rewrite the formula as. Sum of divisors = (p1a1+1 - 1)/(p1 -1) * (p2a2+1 - 1)/(p2 -1) * .................................. (pkak+1 - 1)/(pk -1)65 729 1 Sum of divisors = (1 + p1 + p12 ... p1a1) * (1 + p2 + p22 ... p2a2) * ............................................. (1 + pk + pk2 ... pkak) We can notice that individual terms of above formula are Geometric Progressions (GP). We can rewrite the formula as. Sum of divisors = (p1a1+1 - 1)/(p1 -1) * (p2a2+1 - 1)/(p2 -1) * .................................. (pkak+1 - 1)/(pk -1)42 Sum of divisors = (1 + p1 + p12 ... p1a1) * (1 + p2 + p22 ... p2a2) * ............................................. (1 + pk + pk2 ... pkak) We can notice that individual terms of above formula are Geometric Progressions (GP). We can rewrite the formula as. Sum of divisors = (p1a1+1 - 1)/(p1 -1) * (p2a2+1 - 1)/(p2 -1) * .................................. (pkak+1 - 1)/(pk -1)9 Sum of divisors = (1 + p1 + p12 ... p1a1) * (1 + p2 + p22 ... p2a2) * ............................................. (1 + pk + pk2 ... pkak) We can notice that individual terms of above formula are Geometric Progressions (GP). We can rewrite the formula as. Sum of divisors = (p1a1+1 - 1)/(p1 -1) * (p2a2+1 - 1)/(p2 -1) * .................................. (pkak+1 - 1)/(pk -1)16
Sum of divisors = (1 + p1 + p12 ... p1a1) * (1 + p2 + p22 ... p2a2) * ............................................. (1 + pk + pk2 ... pkak) We can notice that individual terms of above formula are Geometric Progressions (GP). We can rewrite the formula as. Sum of divisors = (p1a1+1 - 1)/(p1 -1) * (p2a2+1 - 1)/(p2 -1) * .................................. (pkak+1 - 1)/(pk -1)18
72
729 5This article is contributed by Aarti_Rathi. Please write comments if you find anything incorrect, or you want to share more information about the topic discussed above Further Optimization. If there are multiple queries, we can use Sieve to find prime factors and their powers. References: https://www.math.upenn.edu/~deturck/m170/wk3/lecture/sumdiv.html http://mathforum.org/library/drmath/view/71550.html Làm thế nào để bạn tìm thấy tổng của tất cả các yếu tố của một số trong Python?Làm thế nào để bạn tìm thấy các yếu tố của một số trong một vòng lặp trong Python ?.. Bước 1 - Lấy số đầu vào từ người dùng .. Bước 2 - Lặp lại cho vòng lặp trên mỗi số từ 1 đến số đã cho .. Bước 3 - Nếu trình lặp vòng lặp phân chia đồng đều số được cung cấp, tức là số % i == 0 in nó .. Bước 4 - Kết quả in .. Làm thế nào để bạn tìm thấy tổng của tất cả các yếu tố của một số?Công thức cho tổng của tất cả các yếu tố được đưa ra bởi;Tổng các yếu tố của n = [(xA+1-1)/x-1] × [(yb+1-1)/y-1] × [(zc+1-1)/z-1]Sum of factors of N = [(Xa+1-1)/X-1] × [(Yb+1-1)/Y-1] × [(Zc+1-1)/Z-1]
Tổng của tất cả các yếu tố của 20 là gì?Tổng của tất cả các yếu tố của 20 là gì?Vì tất cả các yếu tố của 20 là 1, 2, 4, 5, 10, 20, do đó, tổng của các yếu tố của nó là 1 + 2 + 4 + 5 + 10 + 20 = 42.42.
Làm cách nào để đếm các yếu tố trong Python?Làm thế nào để tính toán tất cả các yếu tố của một số nhất định trong Python.. Chúng tôi xác định một hàm getFactors () lấy một số làm đầu vào và trả về danh sách các yếu tố ;. Hàm này ban đầu tạo ra một danh sách trống ;. Hàm sau đó lặp qua số 1 đến N bằng cách sử dụng phạm vi hàm tích hợp (); |