Tìm tất cả các ước của một số python
|
Viết chương trình Python để tìm tất cả các ước của một số nguyên hoặc số bằng vòng lặp for. Trong ví dụ Python này, vòng lặp for lặp từ 1 đến một số đã cho và kiểm tra xem mỗi số có chia hết cho số không. Nếu Đúng, in số đó dưới dạng ước số
Show
num = int(input("Please enter any integer to find divisors = "))
print("The Divisors of the Number = ")
for i in range(1, num + 1):
if num % i == 0:
print(i)
Chương trình Python tìm tất cả các ước của một số nguyên bằng vòng lặp while num = int(input("Please enter any integer to find divisors = "))
i = 1
while(i <= num):
if num % i == 0:
print(i)
i = i + 1
Trong ví dụ Python này, chúng tôi đã tạo một hàm findDivisors sẽ tìm và trả về tất cả các ước của một số đã cho def findDivisors(num):
for i in range(1, num + 1):
if num % i == 0:
print(i)
# End of Function
num = int(input("Please enter any integer to find divisors = "))
findDivisors(num)
The divisors of 100 are: 1 2 4 5 10 20 25 50 1006_______6_______3 n = 10
from 1 to 10
keep checking n % 1 == 0 print 1
n % 2 == 0 print 2
3, 4, 5, 6, 7, 8, 9 will not give remainder 0
exit loop;
The 1 and 2 which gives remainder as 0 it also mean that n is perfectly divisible by 1 and 2 so in second for loop keep printing the quotient on dividing by 1 and 2 which left remainder 0
from 10 to 1
keep checking n % 1 == 0 print n/1
n % 2 == 0 print n/2
exit loop4
The divisors of 100 are: 1 2 4 5 10 20 25 50 1003 n = 10
from 1 to 10
keep checking n % 1 == 0 print 1
n % 2 == 0 print 2
3, 4, 5, 6, 7, 8, 9 will not give remainder 0
exit loop;
The 1 and 2 which gives remainder as 0 it also mean that n is perfectly divisible by 1 and 2 so in second for loop keep printing the quotient on dividing by 1 and 2 which left remainder 0
from 10 to 1
keep checking n % 1 == 0 print n/1
n % 2 == 0 print n/2
exit loop6
n = 10
from 1 to 10
keep checking n % 1 == 0 print 1
n % 2 == 0 print 2
3, 4, 5, 6, 7, 8, 9 will not give remainder 0
exit loop;
The 1 and 2 which gives remainder as 0 it also mean that n is perfectly divisible by 1 and 2 so in second for loop keep printing the quotient on dividing by 1 and 2 which left remainder 0
from 10 to 1
keep checking n % 1 == 0 print n/1
n % 2 == 0 print n/2
exit loop7_______6_______8
n = 10
from 1 to 10
keep checking n % 1 == 0 print 1
n % 2 == 0 print 2
3, 4, 5, 6, 7, 8, 9 will not give remainder 0
exit loop;
The 1 and 2 which gives remainder as 0 it also mean that n is perfectly divisible by 1 and 2 so in second for loop keep printing the quotient on dividing by 1 and 2 which left remainder 0
from 10 to 1
keep checking n % 1 == 0 print n/1
n % 2 == 0 print n/2
exit loop9
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_______5_______3 The divisors of 100 are: 1 2 4 5 10 20 25 50 1002_______5_______0 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 1007 The divisors of 100 are: 1 2 4 5 10 20 25 50 1008 n = 10
from 1 to 10
keep checking n % 1 == 0 print 1
n % 2 == 0 print 2
3, 4, 5, 6, 7, 8, 9 will not give remainder 0
exit loop;
The 1 and 2 which gives remainder as 0 it also mean that n is perfectly divisible by 1 and 2 so in second for loop keep printing the quotient on dividing by 1 and 2 which left remainder 0
from 10 to 1
keep checking n % 1 == 0 print n/1
n % 2 == 0 print n/2
exit loop4// A O(sqrt(n)) program that prints all divisors0// A O(sqrt(n)) program that prints all divisors1
The divisors of 100 are: 1 2 4 5 10 20 25 50 1002_______660_______3 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 1007 The divisors of 100 are: 1 2 4 5 10 20 25 50 1008 n = 10
from 1 to 10
keep checking n % 1 == 0 print 1
n % 2 == 0 print 2
3, 4, 5, 6, 7, 8, 9 will not give remainder 0
exit loop;
The 1 and 2 which gives remainder as 0 it also mean that n is perfectly divisible by 1 and 2 so in second for loop keep printing the quotient on dividing by 1 and 2 which left remainder 0
from 10 to 1
keep checking n % 1 == 0 print n/1
n % 2 == 0 print n/2
exit loop4// A O(sqrt(n)) program that prints all divisors0// A O(sqrt(n)) program that prints all divisors1
The divisors of 100 are: 1 2 4 5 10 20 25 50 1007 // in sorted order1
The divisors of 100 are: 1 2 4 5 10 20 25 50 1007 // in sorted order3
The divisors of 100 are: 1 2 4 5 10 20 25 50 1002_______665_______5 n = 10
from 1 to 10
keep checking n % 1 == 0 print 1
n % 2 == 0 print 2
3, 4, 5, 6, 7, 8, 9 will not give remainder 0
exit loop;
The 1 and 2 which gives remainder as 0 it also mean that n is perfectly divisible by 1 and 2 so in second for loop keep printing the quotient on dividing by 1 and 2 which left remainder 0
from 10 to 1
keep checking n % 1 == 0 print n/1
n % 2 == 0 print n/2
exit loop9// in sorted order5
The divisors of 100 are: 1 2 4 5 10 20 25 50 1006_______665_______5
The divisors of 100 are: 1 2 4 5 10 20 25 50 1006_______670_______1 The divisors of 100 are: 1 2 4 5 10 20 25 50 1006_______6_______3 n = 10
from 1 to 10
keep checking n % 1 == 0 print 1
n % 2 == 0 print 2
3, 4, 5, 6, 7, 8, 9 will not give remainder 0
exit loop;
The 1 and 2 which gives remainder as 0 it also mean that n is perfectly divisible by 1 and 2 so in second for loop keep printing the quotient on dividing by 1 and 2 which left remainder 0
from 10 to 1
keep checking n % 1 == 0 print n/1
n % 2 == 0 print n/2
exit loop4
The divisors of 100 are: 1 2 4 5 10 20 25 50 1003 #include 6
n = 10
from 1 to 10
keep checking n % 1 == 0 print 1
n % 2 == 0 print 2
3, 4, 5, 6, 7, 8, 9 will not give remainder 0
exit loop;
The 1 and 2 which gives remainder as 0 it also mean that n is perfectly divisible by 1 and 2 so in second for loop keep printing the quotient on dividing by 1 and 2 which left remainder 0
from 10 to 1
keep checking n % 1 == 0 print n/1
n % 2 == 0 print n/2
exit loop9
The divisors of 100 are: 1 2 4 5 10 20 25 50 1008 n = 10
from 1 to 10
keep checking n % 1 == 0 print 1
n % 2 == 0 print 2
3, 4, 5, 6, 7, 8, 9 will not give remainder 0
exit loop;
The 1 and 2 which gives remainder as 0 it also mean that n is perfectly divisible by 1 and 2 so in second for loop keep printing the quotient on dividing by 1 and 2 which left remainder 0
from 10 to 1
keep checking n % 1 == 0 print n/1
n % 2 == 0 print n/2
exit loop4// A O(sqrt(n)) program that prints all divisors0using1
The divisors of 100 are: 1 2 4 5 10 20 25 50 1003 using5
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_______5_______8 n = 10
from 1 to 10
keep checking n % 1 == 0 print 1
n % 2 == 0 print 2
3, 4, 5, 6, 7, 8, 9 will not give remainder 0
exit loop;
The 1 and 2 which gives remainder as 0 it also mean that n is perfectly divisible by 1 and 2 so in second for loop keep printing the quotient on dividing by 1 and 2 which left remainder 0
from 10 to 1
keep checking n % 1 == 0 print n/1
n % 2 == 0 print n/2
exit loop4namespace0namespace1
The divisors of 100 are: 1 2 4 5 10 20 25 50 1006_______677_______3 The divisors of 100 are: 1 2 4 5 10 20 25 50 1006_______677_______5 namespace6
Java
The divisors of 100 are: 1 2 4 5 10 20 25 50 1006_______685_______5 The divisors of 100 are: 1 2 4 5 10 20 25 50 1006_______685_______7 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_______5_______3 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_______5_______5 n = 10
from 1 to 10
keep checking n % 1 == 0 print 1
n % 2 == 0 print 2
3, 4, 5, 6, 7, 8, 9 will not give remainder 0
exit loop;
The 1 and 2 which gives remainder as 0 it also mean that n is perfectly divisible by 1 and 2 so in second for loop keep printing the quotient on dividing by 1 and 2 which left remainder 0
from 10 to 1
keep checking n % 1 == 0 print n/1
n % 2 == 0 print n/2
exit loop9
The divisors of 100 are: 1 2 4 5 10 20 25 50 1007 n = 10
from 1 to 10
keep checking n % 1 == 0 print 1
n % 2 == 0 print 2
3, 4, 5, 6, 7, 8, 9 will not give remainder 0
exit loop;
The 1 and 2 which gives remainder as 0 it also mean that n is perfectly divisible by 1 and 2 so in second for loop keep printing the quotient on dividing by 1 and 2 which left remainder 0
from 10 to 1
keep checking n % 1 == 0 print n/1
n % 2 == 0 print n/2
exit loop9
The divisors of 100 are: 1 2 4 5 10 20 25 50 10007_______5_______08 The divisors of 100 are: 1 2 4 5 10 20 25 50 10009 n = 10
from 1 to 10
keep checking n % 1 == 0 print 1
n % 2 == 0 print 2
3, 4, 5, 6, 7, 8, 9 will not give remainder 0
exit loop;
The 1 and 2 which gives remainder as 0 it also mean that n is perfectly divisible by 1 and 2 so in second for loop keep printing the quotient on dividing by 1 and 2 which left remainder 0
from 10 to 1
keep checking n % 1 == 0 print n/1
n % 2 == 0 print n/2
exit loop9
n = 10
from 1 to 10
keep checking n % 1 == 0 print 1
n % 2 == 0 print 2
3, 4, 5, 6, 7, 8, 9 will not give remainder 0
exit loop;
The 1 and 2 which gives remainder as 0 it also mean that n is perfectly divisible by 1 and 2 so in second for loop keep printing the quotient on dividing by 1 and 2 which left remainder 0
from 10 to 1
keep checking n % 1 == 0 print n/1
n % 2 == 0 print n/2
exit loop3
n = 10
from 1 to 10
keep checking n % 1 == 0 print 1
n % 2 == 0 print 2
3, 4, 5, 6, 7, 8, 9 will not give remainder 0
exit loop;
The 1 and 2 which gives remainder as 0 it also mean that n is perfectly divisible by 1 and 2 so in second for loop keep printing the quotient on dividing by 1 and 2 which left remainder 0
from 10 to 1
keep checking n % 1 == 0 print n/1
n % 2 == 0 print n/2
exit loop4_______5_______3
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_______5_______16 The divisors of 100 are: 1 2 4 5 10 20 25 50 1002_______5_______0 The divisors of 100 are: 1 2 4 5 10 20 25 50 10019_______5_______20 The divisors of 100 are: 1 2 4 5 10 20 25 50 10021
The divisors of 100 are: 1 2 4 5 10 20 25 50 1007_______5_______3 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 1000 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 10027 The divisors of 100 are: 1 2 4 5 10 20 25 50 10028 // A O(sqrt(n)) program that prints all divisors0// A O(sqrt(n)) program that prints all divisors1
The divisors of 100 are: 1 2 4 5 10 20 25 50 1007 // A O(sqrt(n)) program that prints all divisors3
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 10027 The divisors of 100 are: 1 2 4 5 10 20 25 50 10028 // A O(sqrt(n)) program that prints all divisors0// A O(sqrt(n)) program that prints all divisors1
The divisors of 100 are: 1 2 4 5 10 20 25 50 10027 // in sorted order1
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 10041 The divisors of 100 are: 1 2 4 5 10 20 25 50 1007 // in sorted order5
The divisors of 100 are: 1 2 4 5 10 20 25 50 1002_______665_______5 n = 10
from 1 to 10
keep checking n % 1 == 0 print 1
n % 2 == 0 print 2
3, 4, 5, 6, 7, 8, 9 will not give remainder 0
exit loop;
The 1 and 2 which gives remainder as 0 it also mean that n is perfectly divisible by 1 and 2 so in second for loop keep printing the quotient on dividing by 1 and 2 which left remainder 0
from 10 to 1
keep checking n % 1 == 0 print n/1
n % 2 == 0 print n/2
exit loop9// in sorted order5
n = 10
from 1 to 10
keep checking n % 1 == 0 print 1
n % 2 == 0 print 2
3, 4, 5, 6, 7, 8, 9 will not give remainder 0
exit loop;
The 1 and 2 which gives remainder as 0 it also mean that n is perfectly divisible by 1 and 2 so in second for loop keep printing the quotient on dividing by 1 and 2 which left remainder 0
from 10 to 1
keep checking n % 1 == 0 print n/1
n % 2 == 0 print n/2
exit loop9#include 1
n = 10
from 1 to 10
keep checking n % 1 == 0 print 1
n % 2 == 0 print 2
3, 4, 5, 6, 7, 8, 9 will not give remainder 0
exit loop;
The 1 and 2 which gives remainder as 0 it also mean that n is perfectly divisible by 1 and 2 so in second for loop keep printing the quotient on dividing by 1 and 2 which left remainder 0
from 10 to 1
keep checking n % 1 == 0 print n/1
n % 2 == 0 print n/2
exit loop9
n = 10
from 1 to 10
keep checking n % 1 == 0 print 1
n % 2 == 0 print 2
3, 4, 5, 6, 7, 8, 9 will not give remainder 0
exit loop;
The 1 and 2 which gives remainder as 0 it also mean that n is perfectly divisible by 1 and 2 so in second for loop keep printing the quotient on dividing by 1 and 2 which left remainder 0
from 10 to 1
keep checking n % 1 == 0 print n/1
n % 2 == 0 print n/2
exit loop3
n = 10
from 1 to 10
keep checking n % 1 == 0 print 1
n % 2 == 0 print 2
3, 4, 5, 6, 7, 8, 9 will not give remainder 0
exit loop;
The 1 and 2 which gives remainder as 0 it also mean that n is perfectly divisible by 1 and 2 so in second for loop keep printing the quotient on dividing by 1 and 2 which left remainder 0
from 10 to 1
keep checking n % 1 == 0 print n/1
n % 2 == 0 print n/2
exit loop4_______5_______3
The divisors of 100 are: 1 2 4 5 10 20 25 50 10054 The divisors of 100 are: 1 2 4 5 10 20 25 50 10015 The divisors of 100 are: 1 2 4 5 10 20 25 50 10056 The divisors of 100 are: 1 2 4 5 10 20 25 50 10020 The divisors of 100 are: 1 2 4 5 10 20 25 50 10058 The divisors of 100 are: 1 2 4 5 10 20 25 50 1002_______5_______28 // A O(sqrt(n)) program that prints all divisors0
The divisors of 100 are: 1 2 4 5 10 20 25 50 10062 The divisors of 100 are: 1 2 4 5 10 20 25 50 1006_______665_______5
The divisors of 100 are: 1 2 4 5 10 20 25 50 1006_______5_______66 The divisors of 100 are: 1 2 4 5 10 20 25 50 1006_______5_______68 std;7
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 10071 The divisors of 100 are: 1 2 4 5 10 20 25 50 1006_______5_______5 n = 10
from 1 to 10
keep checking n % 1 == 0 print 1
n % 2 == 0 print 2
3, 4, 5, 6, 7, 8, 9 will not give remainder 0
exit loop;
The 1 and 2 which gives remainder as 0 it also mean that n is perfectly divisible by 1 and 2 so in second for loop keep printing the quotient on dividing by 1 and 2 which left remainder 0
from 10 to 1
keep checking n % 1 == 0 print n/1
n % 2 == 0 print n/2
exit loop9
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 10076 namespace1
n = 10
from 1 to 10
keep checking n % 1 == 0 print 1
n % 2 == 0 print 2
3, 4, 5, 6, 7, 8, 9 will not give remainder 0
exit loop;
The 1 and 2 which gives remainder as 0 it also mean that n is perfectly divisible by 1 and 2 so in second for loop keep printing the quotient on dividing by 1 and 2 which left remainder 0
from 10 to 1
keep checking n % 1 == 0 print n/1
n % 2 == 0 print n/2
exit loop9
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 10080 namespace1
The divisors of 100 are: 1 2 4 5 10 20 25 50 1006_______665_______5
Python3
The divisors of 100 are: 1 2 4 5 10 20 25 50 10085 The divisors of 100 are: 1 2 4 5 10 20 25 50 10086
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
The divisors of 100 are: 1 2 4 5 10 20 25 50 10090 The divisors of 100 are: 1 2 4 5 10 20 25 50 10091 The divisors of 100 are: 1 2 4 5 10 20 25 50 1006_______5_______93 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_______5_______97 The divisors of 100 are: 1 2 4 5 10 20 25 50 1006_______6_______3 n = 10
from 1 to 10
keep checking n % 1 == 0 print 1
n % 2 == 0 print 2
3, 4, 5, 6, 7, 8, 9 will not give remainder 0
exit loop;
The 1 and 2 which gives remainder as 0 it also mean that n is perfectly divisible by 1 and 2 so in second for loop keep printing the quotient on dividing by 1 and 2 which left remainder 0
from 10 to 1
keep checking n % 1 == 0 print n/1
n % 2 == 0 print n/2
exit loop00_______6_______01
n = 10
from 1 to 10
keep checking n % 1 == 0 print 1
n % 2 == 0 print 2
3, 4, 5, 6, 7, 8, 9 will not give remainder 0
exit loop;
The 1 and 2 which gives remainder as 0 it also mean that n is perfectly divisible by 1 and 2 so in second for loop keep printing the quotient on dividing by 1 and 2 which left remainder 0
from 10 to 1
keep checking n % 1 == 0 print n/1
n % 2 == 0 print n/2
exit loop02
n = 10
from 1 to 10
keep checking n % 1 == 0 print 1
n % 2 == 0 print 2
3, 4, 5, 6, 7, 8, 9 will not give remainder 0
exit loop;
The 1 and 2 which gives remainder as 0 it also mean that n is perfectly divisible by 1 and 2 so in second for loop keep printing the quotient on dividing by 1 and 2 which left remainder 0
from 10 to 1
keep checking n % 1 == 0 print n/1
n % 2 == 0 print n/2
exit loop4
The divisors of 100 are: 1 2 4 5 10 20 25 50 10015 n = 10
from 1 to 10
keep checking n % 1 == 0 print 1
n % 2 == 0 print 2
3, 4, 5, 6, 7, 8, 9 will not give remainder 0
exit loop;
The 1 and 2 which gives remainder as 0 it also mean that n is perfectly divisible by 1 and 2 so in second for loop keep printing the quotient on dividing by 1 and 2 which left remainder 0
from 10 to 1
keep checking n % 1 == 0 print n/1
n % 2 == 0 print n/2
exit loop05_______5_______3_______6_______07
n = 10
from 1 to 10
keep checking n % 1 == 0 print 1
n % 2 == 0 print 2
3, 4, 5, 6, 7, 8, 9 will not give remainder 0
exit loop;
The 1 and 2 which gives remainder as 0 it also mean that n is perfectly divisible by 1 and 2 so in second for loop keep printing the quotient on dividing by 1 and 2 which left remainder 0
from 10 to 1
keep checking n % 1 == 0 print n/1
n % 2 == 0 print n/2
exit loop08
The divisors of 100 are: 1 2 4 5 10 20 25 50 10015 n = 10
from 1 to 10
keep checking n % 1 == 0 print 1
n % 2 == 0 print 2
3, 4, 5, 6, 7, 8, 9 will not give remainder 0
exit loop;
The 1 and 2 which gives remainder as 0 it also mean that n is perfectly divisible by 1 and 2 so in second for loop keep printing the quotient on dividing by 1 and 2 which left remainder 0
from 10 to 1
keep checking n % 1 == 0 print n/1
n % 2 == 0 print n/2
exit loop10
n = 10
from 1 to 10
keep checking n % 1 == 0 print 1
n % 2 == 0 print 2
3, 4, 5, 6, 7, 8, 9 will not give remainder 0
exit loop;
The 1 and 2 which gives remainder as 0 it also mean that n is perfectly divisible by 1 and 2 so in second for loop keep printing the quotient on dividing by 1 and 2 which left remainder 0
from 10 to 1
keep checking n % 1 == 0 print n/1
n % 2 == 0 print n/2
exit loop9
The divisors of 100 are: 1 2 4 5 10 20 25 50 1000 n = 10
from 1 to 10
keep checking n % 1 == 0 print 1
n % 2 == 0 print 2
3, 4, 5, 6, 7, 8, 9 will not give remainder 0
exit loop;
The 1 and 2 which gives remainder as 0 it also mean that n is perfectly divisible by 1 and 2 so in second for loop keep printing the quotient on dividing by 1 and 2 which left remainder 0
from 10 to 1
keep checking n % 1 == 0 print n/1
n % 2 == 0 print n/2
exit loop13_______6_______14
n = 10
from 1 to 10
keep checking n % 1 == 0 print 1
n % 2 == 0 print 2
3, 4, 5, 6, 7, 8, 9 will not give remainder 0
exit loop;
The 1 and 2 which gives remainder as 0 it also mean that n is perfectly divisible by 1 and 2 so in second for loop keep printing the quotient on dividing by 1 and 2 which left remainder 0
from 10 to 1
keep checking n % 1 == 0 print n/1
n % 2 == 0 print n/2
exit loop00
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 10094 The divisors of 100 are: 1 2 4 5 10 20 25 50 10020 n = 10
from 1 to 10
keep checking n % 1 == 0 print 1
n % 2 == 0 print 2
3, 4, 5, 6, 7, 8, 9 will not give remainder 0
exit loop;
The 1 and 2 which gives remainder as 0 it also mean that n is perfectly divisible by 1 and 2 so in second for loop keep printing the quotient on dividing by 1 and 2 which left remainder 0
from 10 to 1
keep checking n % 1 == 0 print n/1
n % 2 == 0 print n/2
exit loop19
The divisors of 100 are: 1 2 4 5 10 20 25 50 1002_______6_______21 The divisors of 100 are: 1 2 4 5 10 20 25 50 1002_______5_______0 n = 10
from 1 to 10
keep checking n % 1 == 0 print 1
n % 2 == 0 print 2
3, 4, 5, 6, 7, 8, 9 will not give remainder 0
exit loop;
The 1 and 2 which gives remainder as 0 it also mean that n is perfectly divisible by 1 and 2 so in second for loop keep printing the quotient on dividing by 1 and 2 which left remainder 0
from 10 to 1
keep checking n % 1 == 0 print n/1
n % 2 == 0 print n/2
exit loop13_______6_______25
n = 10
from 1 to 10
keep checking n % 1 == 0 print 1
n % 2 == 0 print 2
3, 4, 5, 6, 7, 8, 9 will not give remainder 0
exit loop;
The 1 and 2 which gives remainder as 0 it also mean that n is perfectly divisible by 1 and 2 so in second for loop keep printing the quotient on dividing by 1 and 2 which left remainder 0
from 10 to 1
keep checking n % 1 == 0 print n/1
n % 2 == 0 print n/2
exit loop00
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 10094 n = 10
from 1 to 10
keep checking n % 1 == 0 print 1
n % 2 == 0 print 2
3, 4, 5, 6, 7, 8, 9 will not give remainder 0
exit loop;
The 1 and 2 which gives remainder as 0 it also mean that n is perfectly divisible by 1 and 2 so in second for loop keep printing the quotient on dividing by 1 and 2 which left remainder 0
from 10 to 1
keep checking n % 1 == 0 print n/1
n % 2 == 0 print n/2
exit loop29
The divisors of 100 are: 1 2 4 5 10 20 25 50 1007 n = 10
from 1 to 10
keep checking n % 1 == 0 print 1
n % 2 == 0 print 2
3, 4, 5, 6, 7, 8, 9 will not give remainder 0
exit loop;
The 1 and 2 which gives remainder as 0 it also mean that n is perfectly divisible by 1 and 2 so in second for loop keep printing the quotient on dividing by 1 and 2 which left remainder 0
from 10 to 1
keep checking n % 1 == 0 print n/1
n % 2 == 0 print n/2
exit loop31
n = 10
from 1 to 10
keep checking n % 1 == 0 print 1
n % 2 == 0 print 2
3, 4, 5, 6, 7, 8, 9 will not give remainder 0
exit loop;
The 1 and 2 which gives remainder as 0 it also mean that n is perfectly divisible by 1 and 2 so in second for loop keep printing the quotient on dividing by 1 and 2 which left remainder 0
from 10 to 1
keep checking n % 1 == 0 print n/1
n % 2 == 0 print n/2
exit loop32
The divisors of 100 are: 1 2 4 5 10 20 25 50 10094 n = 10
from 1 to 10
keep checking n % 1 == 0 print 1
n % 2 == 0 print 2
3, 4, 5, 6, 7, 8, 9 will not give remainder 0
exit loop;
The 1 and 2 which gives remainder as 0 it also mean that n is perfectly divisible by 1 and 2 so in second for loop keep printing the quotient on dividing by 1 and 2 which left remainder 0
from 10 to 1
keep checking n % 1 == 0 print n/1
n % 2 == 0 print n/2
exit loop34
n = 10
from 1 to 10
keep checking n % 1 == 0 print 1
n % 2 == 0 print 2
3, 4, 5, 6, 7, 8, 9 will not give remainder 0
exit loop;
The 1 and 2 which gives remainder as 0 it also mean that n is perfectly divisible by 1 and 2 so in second for loop keep printing the quotient on dividing by 1 and 2 which left remainder 0
from 10 to 1
keep checking n % 1 == 0 print n/1
n % 2 == 0 print n/2
exit loop35
The divisors of 100 are: 1 2 4 5 10 20 25 50 1002_______660_______3_______6_______38 The divisors of 100 are: 1 2 4 5 10 20 25 50 1007 n = 10
from 1 to 10
keep checking n % 1 == 0 print 1
n % 2 == 0 print 2
3, 4, 5, 6, 7, 8, 9 will not give remainder 0
exit loop;
The 1 and 2 which gives remainder as 0 it also mean that n is perfectly divisible by 1 and 2 so in second for loop keep printing the quotient on dividing by 1 and 2 which left remainder 0
from 10 to 1
keep checking n % 1 == 0 print n/1
n % 2 == 0 print n/2
exit loop40
The divisors of 100 are: 1 2 4 5 10 20 25 50 1007 n = 10
from 1 to 10
keep checking n % 1 == 0 print 1
n % 2 == 0 print 2
3, 4, 5, 6, 7, 8, 9 will not give remainder 0
exit loop;
The 1 and 2 which gives remainder as 0 it also mean that n is perfectly divisible by 1 and 2 so in second for loop keep printing the quotient on dividing by 1 and 2 which left remainder 0
from 10 to 1
keep checking n % 1 == 0 print n/1
n % 2 == 0 print n/2
exit loop31
n = 10
from 1 to 10
keep checking n % 1 == 0 print 1
n % 2 == 0 print 2
3, 4, 5, 6, 7, 8, 9 will not give remainder 0
exit loop;
The 1 and 2 which gives remainder as 0 it also mean that n is perfectly divisible by 1 and 2 so in second for loop keep printing the quotient on dividing by 1 and 2 which left remainder 0
from 10 to 1
keep checking n % 1 == 0 print n/1
n % 2 == 0 print n/2
exit loop32
The divisors of 100 are: 1 2 4 5 10 20 25 50 10094 n = 10
from 1 to 10
keep checking n % 1 == 0 print 1
n % 2 == 0 print 2
3, 4, 5, 6, 7, 8, 9 will not give remainder 0
exit loop;
The 1 and 2 which gives remainder as 0 it also mean that n is perfectly divisible by 1 and 2 so in second for loop keep printing the quotient on dividing by 1 and 2 which left remainder 0
from 10 to 1
keep checking n % 1 == 0 print n/1
n % 2 == 0 print n/2
exit loop34
n = 10
from 1 to 10
keep checking n % 1 == 0 print 1
n % 2 == 0 print 2
3, 4, 5, 6, 7, 8, 9 will not give remainder 0
exit loop;
The 1 and 2 which gives remainder as 0 it also mean that n is perfectly divisible by 1 and 2 so in second for loop keep printing the quotient on dividing by 1 and 2 which left remainder 0
from 10 to 1
keep checking n % 1 == 0 print n/1
n % 2 == 0 print n/2
exit loop35
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 10093 n = 10
from 1 to 10
keep checking n % 1 == 0 print 1
n % 2 == 0 print 2
3, 4, 5, 6, 7, 8, 9 will not give remainder 0
exit loop;
The 1 and 2 which gives remainder as 0 it also mean that n is perfectly divisible by 1 and 2 so in second for loop keep printing the quotient on dividing by 1 and 2 which left remainder 0
from 10 to 1
keep checking n % 1 == 0 print n/1
n % 2 == 0 print n/2
exit loop49
The divisors of 100 are: 1 2 4 5 10 20 25 50 1003 n = 10
from 1 to 10
keep checking n % 1 == 0 print 1
n % 2 == 0 print 2
3, 4, 5, 6, 7, 8, 9 will not give remainder 0
exit loop;
The 1 and 2 which gives remainder as 0 it also mean that n is perfectly divisible by 1 and 2 so in second for loop keep printing the quotient on dividing by 1 and 2 which left remainder 0
from 10 to 1
keep checking n % 1 == 0 print n/1
n % 2 == 0 print n/2
exit loop13
n = 10
from 1 to 10
keep checking n % 1 == 0 print 1
n % 2 == 0 print 2
3, 4, 5, 6, 7, 8, 9 will not give remainder 0
exit loop;
The 1 and 2 which gives remainder as 0 it also mean that n is perfectly divisible by 1 and 2 so in second for loop keep printing the quotient on dividing by 1 and 2 which left remainder 0
from 10 to 1
keep checking n % 1 == 0 print n/1
n % 2 == 0 print n/2
exit loop25
n = 10
from 1 to 10
keep checking n % 1 == 0 print 1
n % 2 == 0 print 2
3, 4, 5, 6, 7, 8, 9 will not give remainder 0
exit loop;
The 1 and 2 which gives remainder as 0 it also mean that n is perfectly divisible by 1 and 2 so in second for loop keep printing the quotient on dividing by 1 and 2 which left remainder 0
from 10 to 1
keep checking n % 1 == 0 print n/1
n % 2 == 0 print n/2
exit loop53
The divisors of 100 are: 1 2 4 5 10 20 25 50 1006_______6_______55 The divisors of 100 are: 1 2 4 5 10 20 25 50 1006_______6_______3 n = 10
from 1 to 10
keep checking n % 1 == 0 print 1
n % 2 == 0 print 2
3, 4, 5, 6, 7, 8, 9 will not give remainder 0
exit loop;
The 1 and 2 which gives remainder as 0 it also mean that n is perfectly divisible by 1 and 2 so in second for loop keep printing the quotient on dividing by 1 and 2 which left remainder 0
from 10 to 1
keep checking n % 1 == 0 print n/1
n % 2 == 0 print n/2
exit loop00_______6_______01
The divisors of 100 are: 1 2 4 5 10 20 25 50 10093 n = 10
from 1 to 10
keep checking n % 1 == 0 print 1
n % 2 == 0 print 2
3, 4, 5, 6, 7, 8, 9 will not give remainder 0
exit loop;
The 1 and 2 which gives remainder as 0 it also mean that n is perfectly divisible by 1 and 2 so in second for loop keep printing the quotient on dividing by 1 and 2 which left remainder 0
from 10 to 1
keep checking n % 1 == 0 print n/1
n % 2 == 0 print n/2
exit loop61
n = 10
from 1 to 10
keep checking n % 1 == 0 print 1
n % 2 == 0 print 2
3, 4, 5, 6, 7, 8, 9 will not give remainder 0
exit loop;
The 1 and 2 which gives remainder as 0 it also mean that n is perfectly divisible by 1 and 2 so in second for loop keep printing the quotient on dividing by 1 and 2 which left remainder 0
from 10 to 1
keep checking n % 1 == 0 print n/1
n % 2 == 0 print n/2
exit loop62
The divisors of 100 are: 1 2 4 5 10 20 25 50 10015 n = 10
from 1 to 10
keep checking n % 1 == 0 print 1
n % 2 == 0 print 2
3, 4, 5, 6, 7, 8, 9 will not give remainder 0
exit loop;
The 1 and 2 which gives remainder as 0 it also mean that n is perfectly divisible by 1 and 2 so in second for loop keep printing the quotient on dividing by 1 and 2 which left remainder 0
from 10 to 1
keep checking n % 1 == 0 print n/1
n % 2 == 0 print n/2
exit loop64
n = 10
from 1 to 10
keep checking n % 1 == 0 print 1
n % 2 == 0 print 2
3, 4, 5, 6, 7, 8, 9 will not give remainder 0
exit loop;
The 1 and 2 which gives remainder as 0 it also mean that n is perfectly divisible by 1 and 2 so in second for loop keep printing the quotient on dividing by 1 and 2 which left remainder 0
from 10 to 1
keep checking n % 1 == 0 print n/1
n % 2 == 0 print n/2
exit loop9
n = 10
from 1 to 10
keep checking n % 1 == 0 print 1
n % 2 == 0 print 2
3, 4, 5, 6, 7, 8, 9 will not give remainder 0
exit loop;
The 1 and 2 which gives remainder as 0 it also mean that n is perfectly divisible by 1 and 2 so in second for loop keep printing the quotient on dividing by 1 and 2 which left remainder 0
from 10 to 1
keep checking n % 1 == 0 print n/1
n % 2 == 0 print n/2
exit loop31
n = 10
from 1 to 10
keep checking n % 1 == 0 print 1
n % 2 == 0 print 2
3, 4, 5, 6, 7, 8, 9 will not give remainder 0
exit loop;
The 1 and 2 which gives remainder as 0 it also mean that n is perfectly divisible by 1 and 2 so in second for loop keep printing the quotient on dividing by 1 and 2 which left remainder 0
from 10 to 1
keep checking n % 1 == 0 print n/1
n % 2 == 0 print n/2
exit loop32
The divisors of 100 are: 1 2 4 5 10 20 25 50 10094 n = 10
from 1 to 10
keep checking n % 1 == 0 print 1
n % 2 == 0 print 2
3, 4, 5, 6, 7, 8, 9 will not give remainder 0
exit loop;
The 1 and 2 which gives remainder as 0 it also mean that n is perfectly divisible by 1 and 2 so in second for loop keep printing the quotient on dividing by 1 and 2 which left remainder 0
from 10 to 1
keep checking n % 1 == 0 print n/1
n % 2 == 0 print n/2
exit loop34
n = 10
from 1 to 10
keep checking n % 1 == 0 print 1
n % 2 == 0 print 2
3, 4, 5, 6, 7, 8, 9 will not give remainder 0
exit loop;
The 1 and 2 which gives remainder as 0 it also mean that n is perfectly divisible by 1 and 2 so in second for loop keep printing the quotient on dividing by 1 and 2 which left remainder 0
from 10 to 1
keep checking n % 1 == 0 print n/1
n % 2 == 0 print n/2
exit loop35
n = 10
from 1 to 10
keep checking n % 1 == 0 print 1
n % 2 == 0 print 2
3, 4, 5, 6, 7, 8, 9 will not give remainder 0
exit loop;
The 1 and 2 which gives remainder as 0 it also mean that n is perfectly divisible by 1 and 2 so in second for loop keep printing the quotient on dividing by 1 and 2 which left remainder 0
from 10 to 1
keep checking n % 1 == 0 print n/1
n % 2 == 0 print n/2
exit loop71
n = 10
from 1 to 10
keep checking n % 1 == 0 print 1
n % 2 == 0 print 2
3, 4, 5, 6, 7, 8, 9 will not give remainder 0
exit loop;
The 1 and 2 which gives remainder as 0 it also mean that n is perfectly divisible by 1 and 2 so in second for loop keep printing the quotient on dividing by 1 and 2 which left remainder 0
from 10 to 1
keep checking n % 1 == 0 print n/1
n % 2 == 0 print n/2
exit loop31_______6_______4_______5_______76
n = 10
from 1 to 10
keep checking n % 1 == 0 print 1
n % 2 == 0 print 2
3, 4, 5, 6, 7, 8, 9 will not give remainder 0
exit loop;
The 1 and 2 which gives remainder as 0 it also mean that n is perfectly divisible by 1 and 2 so in second for loop keep printing the quotient on dividing by 1 and 2 which left remainder 0
from 10 to 1
keep checking n % 1 == 0 print n/1
n % 2 == 0 print n/2
exit loop35
The divisors of 100 are: 1 2 4 5 10 20 25 50 1002_______5_______80 n = 10
from 1 to 10
keep checking n % 1 == 0 print 1
n % 2 == 0 print 2
3, 4, 5, 6, 7, 8, 9 will not give remainder 0
exit loop;
The 1 and 2 which gives remainder as 0 it also mean that n is perfectly divisible by 1 and 2 so in second for loop keep printing the quotient on dividing by 1 and 2 which left remainder 0
from 10 to 1
keep checking n % 1 == 0 print n/1
n % 2 == 0 print n/2
exit loop35
n = 10
from 1 to 10
keep checking n % 1 == 0 print 1
n % 2 == 0 print 2
3, 4, 5, 6, 7, 8, 9 will not give remainder 0
exit loop;
The 1 and 2 which gives remainder as 0 it also mean that n is perfectly divisible by 1 and 2 so in second for loop keep printing the quotient on dividing by 1 and 2 which left remainder 0
from 10 to 1
keep checking n % 1 == 0 print n/1
n % 2 == 0 print n/2
exit loop79
C#
n = 10
from 1 to 10
keep checking n % 1 == 0 print 1
n % 2 == 0 print 2
3, 4, 5, 6, 7, 8, 9 will not give remainder 0
exit loop;
The 1 and 2 which gives remainder as 0 it also mean that n is perfectly divisible by 1 and 2 so in second for loop keep printing the quotient on dividing by 1 and 2 which left remainder 0
from 10 to 1
keep checking n % 1 == 0 print n/1
n % 2 == 0 print n/2
exit loop80
n = 10
from 1 to 10
keep checking n % 1 == 0 print 1
n % 2 == 0 print 2
3, 4, 5, 6, 7, 8, 9 will not give remainder 0
exit loop;
The 1 and 2 which gives remainder as 0 it also mean that n is perfectly divisible by 1 and 2 so in second for loop keep printing the quotient on dividing by 1 and 2 which left remainder 0
from 10 to 1
keep checking n % 1 == 0 print n/1
n % 2 == 0 print n/2
exit loop81
n = 10
from 1 to 10
keep checking n % 1 == 0 print 1
n % 2 == 0 print 2
3, 4, 5, 6, 7, 8, 9 will not give remainder 0
exit loop;
The 1 and 2 which gives remainder as 0 it also mean that n is perfectly divisible by 1 and 2 so in second for loop keep printing the quotient on dividing by 1 and 2 which left remainder 0
from 10 to 1
keep checking n % 1 == 0 print n/1
n % 2 == 0 print n/2
exit loop83
n = 10
from 1 to 10
keep checking n % 1 == 0 print 1
n % 2 == 0 print 2
3, 4, 5, 6, 7, 8, 9 will not give remainder 0
exit loop;
The 1 and 2 which gives remainder as 0 it also mean that n is perfectly divisible by 1 and 2 so in second for loop keep printing the quotient on dividing by 1 and 2 which left remainder 0
from 10 to 1
keep checking n % 1 == 0 print n/1
n % 2 == 0 print n/2
exit loop85
The divisors of 100 are: 1 2 4 5 10 20 25 50 1006_______685_______5 The divisors of 100 are: 1 2 4 5 10 20 25 50 1006_______685_______7 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_______5_______3 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_______5_______5 n = 10
from 1 to 10
keep checking n % 1 == 0 print 1
n % 2 == 0 print 2
3, 4, 5, 6, 7, 8, 9 will not give remainder 0
exit loop;
The 1 and 2 which gives remainder as 0 it also mean that n is perfectly divisible by 1 and 2 so in second for loop keep printing the quotient on dividing by 1 and 2 which left remainder 0
from 10 to 1
keep checking n % 1 == 0 print n/1
n % 2 == 0 print n/2
exit loop9
n = 10
from 1 to 10
keep checking n % 1 == 0 print 1
n % 2 == 0 print 2
3, 4, 5, 6, 7, 8, 9 will not give remainder 0
exit loop;
The 1 and 2 which gives remainder as 0 it also mean that n is perfectly divisible by 1 and 2 so in second for loop keep printing the quotient on dividing by 1 and 2 which left remainder 0
from 10 to 1
keep checking n % 1 == 0 print n/1
n % 2 == 0 print n/2
exit loop97
n = 10
from 1 to 10
keep checking n % 1 == 0 print 1
n % 2 == 0 print 2
3, 4, 5, 6, 7, 8, 9 will not give remainder 0
exit loop;
The 1 and 2 which gives remainder as 0 it also mean that n is perfectly divisible by 1 and 2 so in second for loop keep printing the quotient on dividing by 1 and 2 which left remainder 0
from 10 to 1
keep checking n % 1 == 0 print n/1
n % 2 == 0 print n/2
exit loop9
n = 10
from 1 to 10
keep checking n % 1 == 0 print 1
n % 2 == 0 print 2
3, 4, 5, 6, 7, 8, 9 will not give remainder 0
exit loop;
The 1 and 2 which gives remainder as 0 it also mean that n is perfectly divisible by 1 and 2 so in second for loop keep printing the quotient on dividing by 1 and 2 which left remainder 0
from 10 to 1
keep checking n % 1 == 0 print n/1
n % 2 == 0 print n/2
exit loop99
n = 10
from 1 to 10
keep checking n % 1 == 0 print 1
n % 2 == 0 print 2
3, 4, 5, 6, 7, 8, 9 will not give remainder 0
exit loop;
The 1 and 2 which gives remainder as 0 it also mean that n is perfectly divisible by 1 and 2 so in second for loop keep printing the quotient on dividing by 1 and 2 which left remainder 0
from 10 to 1
keep checking n % 1 == 0 print n/1
n % 2 == 0 print n/2
exit loop9
The divisors of 100 are: 1 2 4 5 10 20 25 50 1003_______5_______02_______5_______08 The divisors of 100 are: 1 2 4 5 10 20 25 50 1003_______5_______05 n = 10
from 1 to 10
keep checking n % 1 == 0 print 1
n % 2 == 0 print 2
3, 4, 5, 6, 7, 8, 9 will not give remainder 0
exit loop;
The 1 and 2 which gives remainder as 0 it also mean that n is perfectly divisible by 1 and 2 so in second for loop keep printing the quotient on dividing by 1 and 2 which left remainder 0
from 10 to 1
keep checking n % 1 == 0 print n/1
n % 2 == 0 print n/2
exit loop9
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 10008 n = 10
from 1 to 10
keep checking n % 1 == 0 print 1
n % 2 == 0 print 2
3, 4, 5, 6, 7, 8, 9 will not give remainder 0
exit loop;
The 1 and 2 which gives remainder as 0 it also mean that n is perfectly divisible by 1 and 2 so in second for loop keep printing the quotient on dividing by 1 and 2 which left remainder 0
from 10 to 1
keep checking n % 1 == 0 print n/1
n % 2 == 0 print n/2
exit loop9
n = 10
from 1 to 10
keep checking n % 1 == 0 print 1
n % 2 == 0 print 2
3, 4, 5, 6, 7, 8, 9 will not give remainder 0
exit loop;
The 1 and 2 which gives remainder as 0 it also mean that n is perfectly divisible by 1 and 2 so in second for loop keep printing the quotient on dividing by 1 and 2 which left remainder 0
from 10 to 1
keep checking n % 1 == 0 print n/1
n % 2 == 0 print n/2
exit loop3
n = 10
from 1 to 10
keep checking n % 1 == 0 print 1
n % 2 == 0 print 2
3, 4, 5, 6, 7, 8, 9 will not give remainder 0
exit loop;
The 1 and 2 which gives remainder as 0 it also mean that n is perfectly divisible by 1 and 2 so in second for loop keep printing the quotient on dividing by 1 and 2 which left remainder 0
from 10 to 1
keep checking n % 1 == 0 print n/1
n % 2 == 0 print n/2
exit loop4
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 10013 The divisors of 100 are: 1 2 4 5 10 20 25 50 1002_______5_______0 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 1007_______5_______3 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 1000 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 10027 The divisors of 100 are: 1 2 4 5 10 20 25 50 10023 n = 10
from 1 to 10
keep checking n % 1 == 0 print 1
n % 2 == 0 print 2
3, 4, 5, 6, 7, 8, 9 will not give remainder 0
exit loop;
The 1 and 2 which gives remainder as 0 it also mean that n is perfectly divisible by 1 and 2 so in second for loop keep printing the quotient on dividing by 1 and 2 which left remainder 0
from 10 to 1
keep checking n % 1 == 0 print n/1
n % 2 == 0 print n/2
exit loop34namespace1
The divisors of 100 are: 1 2 4 5 10 20 25 50 1007 // A O(sqrt(n)) program that prints all divisors3
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 10027 The divisors of 100 are: 1 2 4 5 10 20 25 50 10023 n = 10
from 1 to 10
keep checking n % 1 == 0 print 1
n % 2 == 0 print 2
3, 4, 5, 6, 7, 8, 9 will not give remainder 0
exit loop;
The 1 and 2 which gives remainder as 0 it also mean that n is perfectly divisible by 1 and 2 so in second for loop keep printing the quotient on dividing by 1 and 2 which left remainder 0
from 10 to 1
keep checking n % 1 == 0 print n/1
n % 2 == 0 print n/2
exit loop34namespace1
The divisors of 100 are: 1 2 4 5 10 20 25 50 10027_______5_______34 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 10036 The divisors of 100 are: 1 2 4 5 10 20 25 50 10027_______5_______38 The divisors of 100 are: 1 2 4 5 10 20 25 50 1007 // in sorted order5
The divisors of 100 are: 1 2 4 5 10 20 25 50 1002_______665_______5 n = 10
from 1 to 10
keep checking n % 1 == 0 print 1
n % 2 == 0 print 2
3, 4, 5, 6, 7, 8, 9 will not give remainder 0
exit loop;
The 1 and 2 which gives remainder as 0 it also mean that n is perfectly divisible by 1 and 2 so in second for loop keep printing the quotient on dividing by 1 and 2 which left remainder 0
from 10 to 1
keep checking n % 1 == 0 print n/1
n % 2 == 0 print n/2
exit loop9// in sorted order5
n = 10
from 1 to 10
keep checking n % 1 == 0 print 1
n % 2 == 0 print 2
3, 4, 5, 6, 7, 8, 9 will not give remainder 0
exit loop;
The 1 and 2 which gives remainder as 0 it also mean that n is perfectly divisible by 1 and 2 so in second for loop keep printing the quotient on dividing by 1 and 2 which left remainder 0
from 10 to 1
keep checking n % 1 == 0 print n/1
n % 2 == 0 print n/2
exit loop9
The divisors of 100 are: 1 2 4 5 10 20 25 50 10046 n = 10
from 1 to 10
keep checking n % 1 == 0 print 1
n % 2 == 0 print 2
3, 4, 5, 6, 7, 8, 9 will not give remainder 0
exit loop;
The 1 and 2 which gives remainder as 0 it also mean that n is perfectly divisible by 1 and 2 so in second for loop keep printing the quotient on dividing by 1 and 2 which left remainder 0
from 10 to 1
keep checking n % 1 == 0 print n/1
n % 2 == 0 print n/2
exit loop9
The divisors of 100 are: 1 2 4 5 10 20 25 50 10048 n = 10
from 1 to 10
keep checking n % 1 == 0 print 1
n % 2 == 0 print 2
3, 4, 5, 6, 7, 8, 9 will not give remainder 0
exit loop;
The 1 and 2 which gives remainder as 0 it also mean that n is perfectly divisible by 1 and 2 so in second for loop keep printing the quotient on dividing by 1 and 2 which left remainder 0
from 10 to 1
keep checking n % 1 == 0 print n/1
n % 2 == 0 print n/2
exit loop9
n = 10
from 1 to 10
keep checking n % 1 == 0 print 1
n % 2 == 0 print 2
3, 4, 5, 6, 7, 8, 9 will not give remainder 0
exit loop;
The 1 and 2 which gives remainder as 0 it also mean that n is perfectly divisible by 1 and 2 so in second for loop keep printing the quotient on dividing by 1 and 2 which left remainder 0
from 10 to 1
keep checking n % 1 == 0 print n/1
n % 2 == 0 print n/2
exit loop3
n = 10
from 1 to 10
keep checking n % 1 == 0 print 1
n % 2 == 0 print 2
3, 4, 5, 6, 7, 8, 9 will not give remainder 0
exit loop;
The 1 and 2 which gives remainder as 0 it also mean that n is perfectly divisible by 1 and 2 so in second for loop keep printing the quotient on dividing by 1 and 2 which left remainder 0
from 10 to 1
keep checking n % 1 == 0 print n/1
n % 2 == 0 print n/2
exit loop4
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 10053 The divisors of 100 are: 1 2 4 5 10 20 25 50 1002_______5_______55 n = 10
from 1 to 10
keep checking n % 1 == 0 print 1
n % 2 == 0 print 2
3, 4, 5, 6, 7, 8, 9 will not give remainder 0
exit loop;
The 1 and 2 which gives remainder as 0 it also mean that n is perfectly divisible by 1 and 2 so in second for loop keep printing the quotient on dividing by 1 and 2 which left remainder 0
from 10 to 1
keep checking n % 1 == 0 print n/1
n % 2 == 0 print n/2
exit loop34namespace1
The divisors of 100 are: 1 2 4 5 10 20 25 50 1006_______665_______5
The divisors of 100 are: 1 2 4 5 10 20 25 50 1006_______5_______61 The divisors of 100 are: 1 2 4 5 10 20 25 50 1006_______5_______68 std;7
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 10066 The divisors of 100 are: 1 2 4 5 10 20 25 50 1006_______5_______5 n = 10
from 1 to 10
keep checking n % 1 == 0 print 1
n % 2 == 0 print 2
3, 4, 5, 6, 7, 8, 9 will not give remainder 0
exit loop;
The 1 and 2 which gives remainder as 0 it also mean that n is perfectly divisible by 1 and 2 so in second for loop keep printing the quotient on dividing by 1 and 2 which left remainder 0
from 10 to 1
keep checking n % 1 == 0 print n/1
n % 2 == 0 print n/2
exit loop9
The divisors of 100 are: 1 2 4 5 10 20 25 50 10070 namespace0namespace1
n = 10
from 1 to 10
keep checking n % 1 == 0 print 1
n % 2 == 0 print 2
3, 4, 5, 6, 7, 8, 9 will not give remainder 0
exit loop;
The 1 and 2 which gives remainder as 0 it also mean that n is perfectly divisible by 1 and 2 so in second for loop keep printing the quotient on dividing by 1 and 2 which left remainder 0
from 10 to 1
keep checking n % 1 == 0 print n/1
n % 2 == 0 print n/2
exit loop9namespace3
The divisors of 100 are: 1 2 4 5 10 20 25 50 1006_______665_______5
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 10079 PHP
The divisors of 100 are: 1 2 4 5 10 20 25 50 10080 The divisors of 100 are: 1 2 4 5 10 20 25 50 10081 The divisors of 100 are: 1 2 4 5 10 20 25 50 10082 The divisors of 100 are: 1 2 4 5 10 20 25 50 10083
The divisors of 100 are: 1 2 4 5 10 20 25 50 10084 The divisors of 100 are: 1 2 4 5 10 20 25 50 10085 The divisors of 100 are: 1 2 4 5 10 20 25 50 10086 The divisors of 100 are: 1 2 4 5 10 20 25 50 1002_______5_______88 n = 10
from 1 to 10
keep checking n % 1 == 0 print 1
n % 2 == 0 print 2
3, 4, 5, 6, 7, 8, 9 will not give remainder 0
exit loop;
The 1 and 2 which gives remainder as 0 it also mean that n is perfectly divisible by 1 and 2 so in second for loop keep printing the quotient on dividing by 1 and 2 which left remainder 0
from 10 to 1
keep checking n % 1 == 0 print n/1
n % 2 == 0 print n/2
exit loop35
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_______6_______97 The divisors of 100 are: 1 2 4 5 10 20 25 50 1006_______6_______99 The divisors of 100 are: 1 2 4 5 10 20 25 50 1006_______5_______96 The divisors of 100 are: 1 2 4 5 10 20 25 50 10097 The divisors of 100 are: 1 2 4 5 10 20 25 50 1006_______5_______99 // A O(sqrt(n)) program that prints all divisors00
The divisors of 100 are: 1 2 4 5 10 20 25 50 1006_______6_______3 n = 10
from 1 to 10
keep checking n % 1 == 0 print 1
n % 2 == 0 print 2
3, 4, 5, 6, 7, 8, 9 will not give remainder 0
exit loop;
The 1 and 2 which gives remainder as 0 it also mean that n is perfectly divisible by 1 and 2 so in second for loop keep printing the quotient on dividing by 1 and 2 which left remainder 0
from 10 to 1
keep checking n % 1 == 0 print n/1
n % 2 == 0 print n/2
exit loop4// A O(sqrt(n)) program that prints all divisors04 // A O(sqrt(n)) program that prints all divisors05
The divisors of 100 are: 1 2 4 5 10 20 25 50 10088 namespace1// A O(sqrt(n)) program that prints all divisors04// A O(sqrt(n)) program that prints all divisors12
The divisors of 100 are: 1 2 4 5 10 20 25 50 1006_______5_______5 n = 10
from 1 to 10
keep checking n % 1 == 0 print 1
n % 2 == 0 print 2
3, 4, 5, 6, 7, 8, 9 will not give remainder 0
exit loop;
The 1 and 2 which gives remainder as 0 it also mean that n is perfectly divisible by 1 and 2 so in second for loop keep printing the quotient on dividing by 1 and 2 which left remainder 0
from 10 to 1
keep checking n % 1 == 0 print n/1
n % 2 == 0 print n/2
exit loop9
The divisors of 100 are: 1 2 4 5 10 20 25 50 1000 n = 10
from 1 to 10
keep checking n % 1 == 0 print 1
n % 2 == 0 print 2
3, 4, 5, 6, 7, 8, 9 will not give remainder 0
exit loop;
The 1 and 2 which gives remainder as 0 it also mean that n is perfectly divisible by 1 and 2 so in second for loop keep printing the quotient on dividing by 1 and 2 which left remainder 0
from 10 to 1
keep checking n % 1 == 0 print n/1
n % 2 == 0 print n/2
exit loop4_______5_______88
n = 10
from 1 to 10
keep checking n % 1 == 0 print 1
n % 2 == 0 print 2
3, 4, 5, 6, 7, 8, 9 will not give remainder 0
exit loop;
The 1 and 2 which gives remainder as 0 it also mean that n is perfectly divisible by 1 and 2 so in second for loop keep printing the quotient on dividing by 1 and 2 which left remainder 0
from 10 to 1
keep checking n % 1 == 0 print n/1
n % 2 == 0 print n/2
exit loop14// A O(sqrt(n)) program that prints all divisors04 // A O(sqrt(n)) program that prints all divisors21
n = 10
from 1 to 10
keep checking n % 1 == 0 print 1
n % 2 == 0 print 2
3, 4, 5, 6, 7, 8, 9 will not give remainder 0
exit loop;
The 1 and 2 which gives remainder as 0 it also mean that n is perfectly divisible by 1 and 2 so in second for loop keep printing the quotient on dividing by 1 and 2 which left remainder 0
from 10 to 1
keep checking n % 1 == 0 print n/1
n % 2 == 0 print n/2
exit loop9
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 1002_______5_______3 The divisors of 100 are: 1 2 4 5 10 20 25 50 1002_______5_______0 // A O(sqrt(n)) program that prints all divisors28_______5_______88
n = 10
from 1 to 10
keep checking n % 1 == 0 print 1
n % 2 == 0 print 2
3, 4, 5, 6, 7, 8, 9 will not give remainder 0
exit loop;
The 1 and 2 which gives remainder as 0 it also mean that n is perfectly divisible by 1 and 2 so in second for loop keep printing the quotient on dividing by 1 and 2 which left remainder 0
from 10 to 1
keep checking n % 1 == 0 print n/1
n % 2 == 0 print n/2
exit loop25// A O(sqrt(n)) program that prints all divisors04 // A O(sqrt(n)) program that prints all divisors32// A O(sqrt(n)) program that prints all divisors04
n = 10
from 1 to 10
keep checking n % 1 == 0 print 1
n % 2 == 0 print 2
3, 4, 5, 6, 7, 8, 9 will not give remainder 0
exit loop;
The 1 and 2 which gives remainder as 0 it also mean that n is perfectly divisible by 1 and 2 so in second for loop keep printing the quotient on dividing by 1 and 2 which left remainder 0
from 10 to 1
keep checking n % 1 == 0 print n/1
n % 2 == 0 print n/2
exit loop35
The divisors of 100 are: 1 2 4 5 10 20 25 50 1007 // A O(sqrt(n)) program that prints all divisors36 // A O(sqrt(n)) program that prints all divisors04 // A O(sqrt(n)) program that prints all divisors38
n = 10
from 1 to 10
keep checking n % 1 == 0 print 1
n % 2 == 0 print 2
3, 4, 5, 6, 7, 8, 9 will not give remainder 0
exit loop;
The 1 and 2 which gives remainder as 0 it also mean that n is perfectly divisible by 1 and 2 so in second for loop keep printing the quotient on dividing by 1 and 2 which left remainder 0
from 10 to 1
keep checking n % 1 == 0 print n/1
n % 2 == 0 print n/2
exit loop34
The divisors of 100 are: 1 2 4 5 10 20 25 50 10097 The divisors of 100 are: 1 2 4 5 10 20 25 50 1002_______660_______3 The divisors of 100 are: 1 2 4 5 10 20 25 50 1002_______5_______5 The divisors of 100 are: 1 2 4 5 10 20 25 50 1007 // A O(sqrt(n)) program that prints all divisors36 // A O(sqrt(n)) program that prints all divisors04 // A O(sqrt(n)) program that prints all divisors38
n = 10
from 1 to 10
keep checking n % 1 == 0 print 1
n % 2 == 0 print 2
3, 4, 5, 6, 7, 8, 9 will not give remainder 0
exit loop;
The 1 and 2 which gives remainder as 0 it also mean that n is perfectly divisible by 1 and 2 so in second for loop keep printing the quotient on dividing by 1 and 2 which left remainder 0
from 10 to 1
keep checking n % 1 == 0 print n/1
n % 2 == 0 print n/2
exit loop34
The divisors of 100 are: 1 2 4 5 10 20 25 50 10097
The divisors of 100 are: 1 2 4 5 10 20 25 50 1007 // A O(sqrt(n)) program that prints all divisors52
The divisors of 100 are: 1 2 4 5 10 20 25 50 1007 // A O(sqrt(n)) program that prints all divisors54
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 10096 // A O(sqrt(n)) program that prints all divisors57
The divisors of 100 are: 1 2 4 5 10 20 25 50 10099 // A O(sqrt(n)) program that prints all divisors59
The divisors of 100 are: 1 2 4 5 10 20 25 50 10088 n = 10
from 1 to 10
keep checking n % 1 == 0 print 1
n % 2 == 0 print 2
3, 4, 5, 6, 7, 8, 9 will not give remainder 0
exit loop;
The 1 and 2 which gives remainder as 0 it also mean that n is perfectly divisible by 1 and 2 so in second for loop keep printing the quotient on dividing by 1 and 2 which left remainder 0
from 10 to 1
keep checking n % 1 == 0 print n/1
n % 2 == 0 print n/2
exit loop25// A O(sqrt(n)) program that prints all divisors04
The divisors of 100 are: 1 2 4 5 10 20 25 50 10097 The divisors of 100 are: 1 2 4 5 10 20 25 50 1002_______665_______5 n = 10
from 1 to 10
keep checking n % 1 == 0 print 1
n % 2 == 0 print 2
3, 4, 5, 6, 7, 8, 9 will not give remainder 0
exit loop;
The 1 and 2 which gives remainder as 0 it also mean that n is perfectly divisible by 1 and 2 so in second for loop keep printing the quotient on dividing by 1 and 2 which left remainder 0
from 10 to 1
keep checking n % 1 == 0 print n/1
n % 2 == 0 print n/2
exit loop9// in sorted order5
The divisors of 100 are: 1 2 4 5 10 20 25 50 1006_______665_______5
The divisors of 100 are: 1 2 4 5 10 20 25 50 1006_______5_______46 The divisors of 100 are: 1 2 4 5 10 20 25 50 1006_______5_______48 The divisors of 100 are: 1 2 4 5 10 20 25 50 1006_______6_______3 n = 10
from 1 to 10
keep checking n % 1 == 0 print 1
n % 2 == 0 print 2
3, 4, 5, 6, 7, 8, 9 will not give remainder 0
exit loop;
The 1 and 2 which gives remainder as 0 it also mean that n is perfectly divisible by 1 and 2 so in second for loop keep printing the quotient on dividing by 1 and 2 which left remainder 0
from 10 to 1
keep checking n % 1 == 0 print n/1
n % 2 == 0 print n/2
exit loop4// A O(sqrt(n)) program that prints all divisors04
The divisors of 100 are: 1 2 4 5 10 20 25 50 10094 // A O(sqrt(n)) program that prints all divisors79
n = 10
from 1 to 10
keep checking n % 1 == 0 print 1
n % 2 == 0 print 2
3, 4, 5, 6, 7, 8, 9 will not give remainder 0
exit loop;
The 1 and 2 which gives remainder as 0 it also mean that n is perfectly divisible by 1 and 2 so in second for loop keep printing the quotient on dividing by 1 and 2 which left remainder 0
from 10 to 1
keep checking n % 1 == 0 print n/1
n % 2 == 0 print n/2
exit loop4
The divisors of 100 are: 1 2 4 5 10 20 25 50 10096 // A O(sqrt(n)) program that prints all divisors82
n = 10
from 1 to 10
keep checking n % 1 == 0 print 1
n % 2 == 0 print 2
3, 4, 5, 6, 7, 8, 9 will not give remainder 0
exit loop;
The 1 and 2 which gives remainder as 0 it also mean that n is perfectly divisible by 1 and 2 so in second for loop keep printing the quotient on dividing by 1 and 2 which left remainder 0
from 10 to 1
keep checking n % 1 == 0 print n/1
n % 2 == 0 print n/2
exit loop9// A O(sqrt(n)) program that prints all divisors36
The divisors of 100 are: 1 2 4 5 10 20 25 50 10096 // A O(sqrt(n)) program that prints all divisors57// A O(sqrt(n)) program that prints all divisors04// A O(sqrt(n)) program that prints all divisors93
n = 10
from 1 to 10
keep checking n % 1 == 0 print 1
n % 2 == 0 print 2
3, 4, 5, 6, 7, 8, 9 will not give remainder 0
exit loop;
The 1 and 2 which gives remainder as 0 it also mean that n is perfectly divisible by 1 and 2 so in second for loop keep printing the quotient on dividing by 1 and 2 which left remainder 0
from 10 to 1
keep checking n % 1 == 0 print n/1
n % 2 == 0 print n/2
exit loop34_______5_______97
The divisors of 100 are: 1 2 4 5 10 20 25 50 10097
Javascript
The divisors of 100 are: 1 2 4 5 10 20 25 50 10081 The divisors of 100 are: 1 2 4 5 10 20 25 50 10082 The divisors of 100 are: 1 2 4 5 10 20 25 50 10083
The divisors of 100 are: 1 2 4 5 10 20 25 50 10084 The divisors of 100 are: 1 2 4 5 10 20 25 50 10085 The divisors of 100 are: 1 2 4 5 10 20 25 50 10086 // in sorted order11
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_______6_______97 The divisors of 100 are: 1 2 4 5 10 20 25 50 1006_______6_______99 The divisors of 100 are: 1 2 4 5 10 20 25 50 1006_______665_______18 The divisors of 100 are: 1 2 4 5 10 20 25 50 1006_______665_______20 The divisors of 100 are: 1 2 4 5 10 20 25 50 1006_______6_______3 // in sorted order23
The divisors of 100 are: 1 2 4 5 10 20 25 50 1006_______5_______5 n = 10
from 1 to 10
keep checking n % 1 == 0 print 1
n % 2 == 0 print 2
3, 4, 5, 6, 7, 8, 9 will not give remainder 0
exit loop;
The 1 and 2 which gives remainder as 0 it also mean that n is perfectly divisible by 1 and 2 so in second for loop keep printing the quotient on dividing by 1 and 2 which left remainder 0
from 10 to 1
keep checking n % 1 == 0 print n/1
n % 2 == 0 print n/2
exit loop9
The divisors of 100 are: 1 2 4 5 10 20 25 50 1000 // in sorted order30
n = 10
from 1 to 10
keep checking n % 1 == 0 print 1
n % 2 == 0 print 2
3, 4, 5, 6, 7, 8, 9 will not give remainder 0
exit loop;
The 1 and 2 which gives remainder as 0 it also mean that n is perfectly divisible by 1 and 2 so in second for loop keep printing the quotient on dividing by 1 and 2 which left remainder 0
from 10 to 1
keep checking n % 1 == 0 print n/1
n % 2 == 0 print n/2
exit loop9
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 1002_______5_______3 The divisors of 100 are: 1 2 4 5 10 20 25 50 1002_______5_______0 // in sorted order37
The divisors of 100 are: 1 2 4 5 10 20 25 50 1007 // in sorted order39
n = 10
from 1 to 10
keep checking n % 1 == 0 print 1
n % 2 == 0 print 2
3, 4, 5, 6, 7, 8, 9 will not give remainder 0
exit loop;
The 1 and 2 which gives remainder as 0 it also mean that n is perfectly divisible by 1 and 2 so in second for loop keep printing the quotient on dividing by 1 and 2 which left remainder 0
from 10 to 1
keep checking n % 1 == 0 print n/1
n % 2 == 0 print n/2
exit loop34namespace1
The divisors of 100 are: 1 2 4 5 10 20 25 50 1002_______660_______3 The divisors of 100 are: 1 2 4 5 10 20 25 50 1002_______5_______5 The divisors of 100 are: 1 2 4 5 10 20 25 50 1007 // in sorted order39
n = 10
from 1 to 10
keep checking n % 1 == 0 print 1
n % 2 == 0 print 2
3, 4, 5, 6, 7, 8, 9 will not give remainder 0
exit loop;
The 1 and 2 which gives remainder as 0 it also mean that n is perfectly divisible by 1 and 2 so in second for loop keep printing the quotient on dividing by 1 and 2 which left remainder 0
from 10 to 1
keep checking n % 1 == 0 print n/1
n % 2 == 0 print n/2
exit loop34namespace1
The divisors of 100 are: 1 2 4 5 10 20 25 50 1007 // A O(sqrt(n)) program that prints all divisors52
The divisors of 100 are: 1 2 4 5 10 20 25 50 1007 // A O(sqrt(n)) program that prints all divisors54
The divisors of 100 are: 1 2 4 5 10 20 25 50 1007 // in sorted order55
The divisors of 100 are: 1 2 4 5 10 20 25 50 1002_______665_______5 n = 10
from 1 to 10
keep checking n % 1 == 0 print 1
n % 2 == 0 print 2
3, 4, 5, 6, 7, 8, 9 will not give remainder 0
exit loop;
The 1 and 2 which gives remainder as 0 it also mean that n is perfectly divisible by 1 and 2 so in second for loop keep printing the quotient on dividing by 1 and 2 which left remainder 0
from 10 to 1
keep checking n % 1 == 0 print n/1
n % 2 == 0 print n/2
exit loop9// in sorted order5
The divisors of 100 are: 1 2 4 5 10 20 25 50 1006_______665_______5
The divisors of 100 are: 1 2 4 5 10 20 25 50 1006_______5_______46 The divisors of 100 are: 1 2 4 5 10 20 25 50 1006_______5_______48 The divisors of 100 are: 1 2 4 5 10 20 25 50 1006_______6_______3 // in sorted order68
n = 10
from 1 to 10
keep checking n % 1 == 0 print 1
n % 2 == 0 print 2
3, 4, 5, 6, 7, 8, 9 will not give remainder 0
exit loop;
The 1 and 2 which gives remainder as 0 it also mean that n is perfectly divisible by 1 and 2 so in second for loop keep printing the quotient on dividing by 1 and 2 which left remainder 0
from 10 to 1
keep checking n % 1 == 0 print n/1
n % 2 == 0 print n/2
exit loop34namespace1
The divisors of 100 are: 1 2 4 5 10 20 25 50 1006_______665_______5
Đầu ra The divisors of 100 are: 1 2 4 5 10 20 25 50 100 Thời gian phức tạp. O(sqrt(n)) Phương pháp 2 Tiếp cận. Trong cách tiếp cận bên dưới bằng cách sử dụng vòng lặp for, trước tiên chúng ta chỉ in các số có phần dư là 0 và một khi chúng ta phá vỡ vòng lặp, chúng ta chỉ in thương của các số có phần còn lại là 0 Hãy hiểu thông qua một ví dụ. n = 10
from 1 to 10
keep checking n % 1 == 0 print 1
n % 2 == 0 print 2
3, 4, 5, 6, 7, 8, 9 will not give remainder 0
exit loop;
The 1 and 2 which gives remainder as 0 it also mean that n is perfectly divisible by 1 and 2 so in second for loop keep printing the quotient on dividing by 1 and 2 which left remainder 0
from 10 to 1
keep checking n % 1 == 0 print n/1
n % 2 == 0 print n/2
exit loop
C++
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_______5_______3 #include 00
The divisors of 100 are: 1 2 4 5 10 20 25 50 1006_______6_______3 #include 03
n = 10
from 1 to 10
keep checking n % 1 == 0 print 1
n % 2 == 0 print 2
3, 4, 5, 6, 7, 8, 9 will not give remainder 0
exit loop;
The 1 and 2 which gives remainder as 0 it also mean that n is perfectly divisible by 1 and 2 so in second for loop keep printing the quotient on dividing by 1 and 2 which left remainder 0
from 10 to 1
keep checking n % 1 == 0 print n/1
n % 2 == 0 print n/2
exit loop9
The divisors of 100 are: 1 2 4 5 10 20 25 50 1000 // in sorted order30
The divisors of 100 are: 1 2 4 5 10 20 25 50 1002_______670_______08 n = 10
from 1 to 10
keep checking n % 1 == 0 print 1
n % 2 == 0 print 2
3, 4, 5, 6, 7, 8, 9 will not give remainder 0
exit loop;
The 1 and 2 which gives remainder as 0 it also mean that n is perfectly divisible by 1 and 2 so in second for loop keep printing the quotient on dividing by 1 and 2 which left remainder 0
from 10 to 1
keep checking n % 1 == 0 print n/1
n % 2 == 0 print n/2
exit loop34
The divisors of 100 are: 1 2 4 5 10 20 25 50 10097 The divisors of 100 are: 1 2 4 5 10 20 25 50 1006_______665_______5 The divisors of 100 are: 1 2 4 5 10 20 25 50 1006_______5_______0 #include 15
n = 10
from 1 to 10
keep checking n % 1 == 0 print 1
n % 2 == 0 print 2
3, 4, 5, 6, 7, 8, 9 will not give remainder 0
exit loop;
The 1 and 2 which gives remainder as 0 it also mean that n is perfectly divisible by 1 and 2 so in second for loop keep printing the quotient on dividing by 1 and 2 which left remainder 0
from 10 to 1
keep checking n % 1 == 0 print n/1
n % 2 == 0 print n/2
exit loop9#include 17
The divisors of 100 are: 1 2 4 5 10 20 25 50 1006_______665_______5 The divisors of 100 are: 1 2 4 5 10 20 25 50 1006_______6_______3 #include 22
n = 10
from 1 to 10
keep checking n % 1 == 0 print 1
n % 2 == 0 print 2
3, 4, 5, 6, 7, 8, 9 will not give remainder 0
exit loop;
The 1 and 2 which gives remainder as 0 it also mean that n is perfectly divisible by 1 and 2 so in second for loop keep printing the quotient on dividing by 1 and 2 which left remainder 0
from 10 to 1
keep checking n % 1 == 0 print n/1
n % 2 == 0 print n/2
exit loop9
The divisors of 100 are: 1 2 4 5 10 20 25 50 1000 // in sorted order30
The divisors of 100 are: 1 2 4 5 10 20 25 50 1002_______670_______27 n = 10
from 1 to 10
keep checking n % 1 == 0 print 1
n % 2 == 0 print 2
3, 4, 5, 6, 7, 8, 9 will not give remainder 0
exit loop;
The 1 and 2 which gives remainder as 0 it also mean that n is perfectly divisible by 1 and 2 so in second for loop keep printing the quotient on dividing by 1 and 2 which left remainder 0
from 10 to 1
keep checking n % 1 == 0 print n/1
n % 2 == 0 print n/2
exit loop34
The divisors of 100 are: 1 2 4 5 10 20 25 50 10097 The divisors of 100 are: 1 2 4 5 10 20 25 50 1006_______665_______5
The divisors of 100 are: 1 2 4 5 10 20 25 50 1003 using5
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_______670_______38 namespace0
The divisors of 100 are: 1 2 4 5 10 20 25 50 10097
The divisors of 100 are: 1 2 4 5 10 20 25 50 1006_______677_______3
The divisors of 100 are: 1 2 4 5 10 20 25 50 1006_______677_______5 namespace6
C
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_______5_______3 #include 00
The divisors of 100 are: 1 2 4 5 10 20 25 50 1006_______6_______3 #include 62
n = 10
from 1 to 10
keep checking n % 1 == 0 print 1
n % 2 == 0 print 2
3, 4, 5, 6, 7, 8, 9 will not give remainder 0
exit loop;
The 1 and 2 which gives remainder as 0 it also mean that n is perfectly divisible by 1 and 2 so in second for loop keep printing the quotient on dividing by 1 and 2 which left remainder 0
from 10 to 1
keep checking n % 1 == 0 print n/1
n % 2 == 0 print n/2
exit loop9
The divisors of 100 are: 1 2 4 5 10 20 25 50 1000 // in sorted order30
The divisors of 100 are: 1 2 4 5 10 20 25 50 1002_______5_______8 n = 10
from 1 to 10
keep checking n % 1 == 0 print 1
n % 2 == 0 print 2
3, 4, 5, 6, 7, 8, 9 will not give remainder 0
exit loop;
The 1 and 2 which gives remainder as 0 it also mean that n is perfectly divisible by 1 and 2 so in second for loop keep printing the quotient on dividing by 1 and 2 which left remainder 0
from 10 to 1
keep checking n % 1 == 0 print n/1
n % 2 == 0 print n/2
exit loop4// A O(sqrt(n)) program that prints all divisors0_______660_______1
The divisors of 100 are: 1 2 4 5 10 20 25 50 1006_______665_______5
The divisors of 100 are: 1 2 4 5 10 20 25 50 1006_______5_______5
The divisors of 100 are: 1 2 4 5 10 20 25 50 1006_______665_______5 The divisors of 100 are: 1 2 4 5 10 20 25 50 1006_______6_______3 #include 22
n = 10
from 1 to 10
keep checking n % 1 == 0 print 1
n % 2 == 0 print 2
3, 4, 5, 6, 7, 8, 9 will not give remainder 0
exit loop;
The 1 and 2 which gives remainder as 0 it also mean that n is perfectly divisible by 1 and 2 so in second for loop keep printing the quotient on dividing by 1 and 2 which left remainder 0
from 10 to 1
keep checking n % 1 == 0 print n/1
n % 2 == 0 print n/2
exit loop9
The divisors of 100 are: 1 2 4 5 10 20 25 50 1000 // in sorted order30
The divisors of 100 are: 1 2 4 5 10 20 25 50 1002_______5_______8 n = 10
from 1 to 10
keep checking n % 1 == 0 print 1
n % 2 == 0 print 2
3, 4, 5, 6, 7, 8, 9 will not give remainder 0
exit loop;
The 1 and 2 which gives remainder as 0 it also mean that n is perfectly divisible by 1 and 2 so in second for loop keep printing the quotient on dividing by 1 and 2 which left remainder 0
from 10 to 1
keep checking n % 1 == 0 print n/1
n % 2 == 0 print n/2
exit loop4// A O(sqrt(n)) program that prints all divisors0_______670_______92
The divisors of 100 are: 1 2 4 5 10 20 25 50 1006_______665_______5
The divisors of 100 are: 1 2 4 5 10 20 25 50 1003 using5
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_______5_______8 n = 10
from 1 to 10
keep checking n % 1 == 0 print 1
n % 2 == 0 print 2
3, 4, 5, 6, 7, 8, 9 will not give remainder 0
exit loop;
The 1 and 2 which gives remainder as 0 it also mean that n is perfectly divisible by 1 and 2 so in second for loop keep printing the quotient on dividing by 1 and 2 which left remainder 0
from 10 to 1
keep checking n % 1 == 0 print n/1
n % 2 == 0 print n/2
exit loop4namespace0namespace1
The divisors of 100 are: 1 2 4 5 10 20 25 50 1006_______677_______3 The divisors of 100 are: 1 2 4 5 10 20 25 50 1006_______677_______5 namespace6
Java
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 10068 std;7
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_______5_______3 #include 00
The divisors of 100 are: 1 2 4 5 10 20 25 50 1006_______6_______3_______673_______30 The divisors of 100 are: 1 2 4 5 10 20 25 50 10015 using32
The divisors of 100 are: 1 2 4 5 10 20 25 50 1006_______5_______5 n = 10
from 1 to 10
keep checking n % 1 == 0 print 1
n % 2 == 0 print 2
3, 4, 5, 6, 7, 8, 9 will not give remainder 0
exit loop;
The 1 and 2 which gives remainder as 0 it also mean that n is perfectly divisible by 1 and 2 so in second for loop keep printing the quotient on dividing by 1 and 2 which left remainder 0
from 10 to 1
keep checking n % 1 == 0 print n/1
n % 2 == 0 print n/2
exit loop9
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 10019_______5_______20_______6_______35 The divisors of 100 are: 1 2 4 5 10 20 25 50 1002_______673_______41____6_______34 namespace1
The divisors of 100 are: 1 2 4 5 10 20 25 50 1006_______665_______5 The divisors of 100 are: 1 2 4 5 10 20 25 50 1006_______5_______0 using48
The divisors of 100 are: 1 2 4 5 10 20 25 50 10015 n = 10
from 1 to 10
keep checking n % 1 == 0 print 1
n % 2 == 0 print 2
3, 4, 5, 6, 7, 8, 9 will not give remainder 0
exit loop;
The 1 and 2 which gives remainder as 0 it also mean that n is perfectly divisible by 1 and 2 so in second for loop keep printing the quotient on dividing by 1 and 2 which left remainder 0
from 10 to 1
keep checking n % 1 == 0 print n/1
n % 2 == 0 print n/2
exit loop35
The divisors of 100 are: 1 2 4 5 10 20 25 50 1006_______5_______5
The divisors of 100 are: 1 2 4 5 10 20 25 50 1006_______665_______5 The divisors of 100 are: 1 2 4 5 10 20 25 50 1006_______6_______3_______673_______59 The divisors of 100 are: 1 2 4 5 10 20 25 50 10015_______5_______58 The divisors of 100 are: 1 2 4 5 10 20 25 50 1006_______5_______5 n = 10
from 1 to 10
keep checking n % 1 == 0 print 1
n % 2 == 0 print 2
3, 4, 5, 6, 7, 8, 9 will not give remainder 0
exit loop;
The 1 and 2 which gives remainder as 0 it also mean that n is perfectly divisible by 1 and 2 so in second for loop keep printing the quotient on dividing by 1 and 2 which left remainder 0
from 10 to 1
keep checking n % 1 == 0 print n/1
n % 2 == 0 print n/2
exit loop9
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 10019_______5_______20_______6_______35 The divisors of 100 are: 1 2 4 5 10 20 25 50 1002_______673_______70 n = 10
from 1 to 10
keep checking n % 1 == 0 print 1
n % 2 == 0 print 2
3, 4, 5, 6, 7, 8, 9 will not give remainder 0
exit loop;
The 1 and 2 which gives remainder as 0 it also mean that n is perfectly divisible by 1 and 2 so in second for loop keep printing the quotient on dividing by 1 and 2 which left remainder 0
from 10 to 1
keep checking n % 1 == 0 print n/1
n % 2 == 0 print n/2
exit loop34namespace1
The divisors of 100 are: 1 2 4 5 10 20 25 50 1006_______665_______5
The divisors of 100 are: 1 2 4 5 10 20 25 50 10068 std;7
The divisors of 100 are: 1 2 4 5 10 20 25 50 1001 using80
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_______5_______75 The divisors of 100 are: 1 2 4 5 10 20 25 50 10076 namespace1
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 1006_______5_______2 The divisors of 100 are: 1 2 4 5 10 20 25 50 10080 namespace1
Python3
The divisors of 100 are: 1 2 4 5 10 20 25 50 10088 std;0 using99
The divisors of 100 are: 1 2 4 5 10 20 25 50 10090 namespace02
The divisors of 100 are: 1 2 4 5 10 20 25 50 1006_______6_______00_______5_______94 The divisors of 100 are: 1 2 4 5 10 20 25 50 10015 The divisors of 100 are: 1 2 4 5 10 20 25 50 1006_______677_______08 namespace09using99 namespace11
n = 10
from 1 to 10
keep checking n % 1 == 0 print 1
n % 2 == 0 print 2
3, 4, 5, 6, 7, 8, 9 will not give remainder 0
exit loop;
The 1 and 2 which gives remainder as 0 it also mean that n is perfectly divisible by 1 and 2 so in second for loop keep printing the quotient on dividing by 1 and 2 which left remainder 0
from 10 to 1
keep checking n % 1 == 0 print n/1
n % 2 == 0 print n/2
exit loop9
The divisors of 100 are: 1 2 4 5 10 20 25 50 1000 n = 10
from 1 to 10
keep checking n % 1 == 0 print 1
n % 2 == 0 print 2
3, 4, 5, 6, 7, 8, 9 will not give remainder 0
exit loop;
The 1 and 2 which gives remainder as 0 it also mean that n is perfectly divisible by 1 and 2 so in second for loop keep printing the quotient on dividing by 1 and 2 which left remainder 0
from 10 to 1
keep checking n % 1 == 0 print n/1
n % 2 == 0 print n/2
exit loop13_______6_______14
n = 10
from 1 to 10
keep checking n % 1 == 0 print 1
n % 2 == 0 print 2
3, 4, 5, 6, 7, 8, 9 will not give remainder 0
exit loop;
The 1 and 2 which gives remainder as 0 it also mean that n is perfectly divisible by 1 and 2 so in second for loop keep printing the quotient on dividing by 1 and 2 which left remainder 0
from 10 to 1
keep checking n % 1 == 0 print n/1
n % 2 == 0 print n/2
exit loop00
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 10094 The divisors of 100 are: 1 2 4 5 10 20 25 50 10020 n = 10
from 1 to 10
keep checking n % 1 == 0 print 1
n % 2 == 0 print 2
3, 4, 5, 6, 7, 8, 9 will not give remainder 0
exit loop;
The 1 and 2 which gives remainder as 0 it also mean that n is perfectly divisible by 1 and 2 so in second for loop keep printing the quotient on dividing by 1 and 2 which left remainder 0
from 10 to 1
keep checking n % 1 == 0 print n/1
n % 2 == 0 print n/2
exit loop19
The divisors of 100 are: 1 2 4 5 10 20 25 50 1002_______6_______31 n = 10
from 1 to 10
keep checking n % 1 == 0 print 1
n % 2 == 0 print 2
3, 4, 5, 6, 7, 8, 9 will not give remainder 0
exit loop;
The 1 and 2 which gives remainder as 0 it also mean that n is perfectly divisible by 1 and 2 so in second for loop keep printing the quotient on dividing by 1 and 2 which left remainder 0
from 10 to 1
keep checking n % 1 == 0 print n/1
n % 2 == 0 print n/2
exit loop32_______5_______94
n = 10
from 1 to 10
keep checking n % 1 == 0 print 1
n % 2 == 0 print 2
3, 4, 5, 6, 7, 8, 9 will not give remainder 0
exit loop;
The 1 and 2 which gives remainder as 0 it also mean that n is perfectly divisible by 1 and 2 so in second for loop keep printing the quotient on dividing by 1 and 2 which left remainder 0
from 10 to 1
keep checking n % 1 == 0 print n/1
n % 2 == 0 print n/2
exit loop34
n = 10
from 1 to 10
keep checking n % 1 == 0 print 1
n % 2 == 0 print 2
3, 4, 5, 6, 7, 8, 9 will not give remainder 0
exit loop;
The 1 and 2 which gives remainder as 0 it also mean that n is perfectly divisible by 1 and 2 so in second for loop keep printing the quotient on dividing by 1 and 2 which left remainder 0
from 10 to 1
keep checking n % 1 == 0 print n/1
n % 2 == 0 print n/2
exit loop35
n = 10
from 1 to 10
keep checking n % 1 == 0 print 1
n % 2 == 0 print 2
3, 4, 5, 6, 7, 8, 9 will not give remainder 0
exit loop;
The 1 and 2 which gives remainder as 0 it also mean that n is perfectly divisible by 1 and 2 so in second for loop keep printing the quotient on dividing by 1 and 2 which left remainder 0
from 10 to 1
keep checking n % 1 == 0 print n/1
n % 2 == 0 print n/2
exit loop9
n = 10
from 1 to 10
keep checking n % 1 == 0 print 1
n % 2 == 0 print 2
3, 4, 5, 6, 7, 8, 9 will not give remainder 0
exit loop;
The 1 and 2 which gives remainder as 0 it also mean that n is perfectly divisible by 1 and 2 so in second for loop keep printing the quotient on dividing by 1 and 2 which left remainder 0
from 10 to 1
keep checking n % 1 == 0 print n/1
n % 2 == 0 print n/2
exit loop00
n = 10
from 1 to 10
keep checking n % 1 == 0 print 1
n % 2 == 0 print 2
3, 4, 5, 6, 7, 8, 9 will not give remainder 0
exit loop;
The 1 and 2 which gives remainder as 0 it also mean that n is perfectly divisible by 1 and 2 so in second for loop keep printing the quotient on dividing by 1 and 2 which left remainder 0
from 10 to 1
keep checking n % 1 == 0 print n/1
n % 2 == 0 print n/2
exit loop08
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 10015
The divisors of 100 are: 1 2 4 5 10 20 25 50 1006_______6_______3 n = 10
from 1 to 10
keep checking n % 1 == 0 print 1
n % 2 == 0 print 2
3, 4, 5, 6, 7, 8, 9 will not give remainder 0
exit loop;
The 1 and 2 which gives remainder as 0 it also mean that n is perfectly divisible by 1 and 2 so in second for loop keep printing the quotient on dividing by 1 and 2 which left remainder 0
from 10 to 1
keep checking n % 1 == 0 print n/1
n % 2 == 0 print n/2
exit loop00
n = 10
from 1 to 10
keep checking n % 1 == 0 print 1
n % 2 == 0 print 2
3, 4, 5, 6, 7, 8, 9 will not give remainder 0
exit loop;
The 1 and 2 which gives remainder as 0 it also mean that n is perfectly divisible by 1 and 2 so in second for loop keep printing the quotient on dividing by 1 and 2 which left remainder 0
from 10 to 1
keep checking n % 1 == 0 print n/1
n % 2 == 0 print n/2
exit loop01
n = 10
from 1 to 10
keep checking n % 1 == 0 print 1
n % 2 == 0 print 2
3, 4, 5, 6, 7, 8, 9 will not give remainder 0
exit loop;
The 1 and 2 which gives remainder as 0 it also mean that n is perfectly divisible by 1 and 2 so in second for loop keep printing the quotient on dividing by 1 and 2 which left remainder 0
from 10 to 1
keep checking n % 1 == 0 print n/1
n % 2 == 0 print n/2
exit loop02
n = 10
from 1 to 10
keep checking n % 1 == 0 print 1
n % 2 == 0 print 2
3, 4, 5, 6, 7, 8, 9 will not give remainder 0
exit loop;
The 1 and 2 which gives remainder as 0 it also mean that n is perfectly divisible by 1 and 2 so in second for loop keep printing the quotient on dividing by 1 and 2 which left remainder 0
from 10 to 1
keep checking n % 1 == 0 print n/1
n % 2 == 0 print n/2
exit loop4
The divisors of 100 are: 1 2 4 5 10 20 25 50 1003 namespace39_______5_______20
n = 10
from 1 to 10
keep checking n % 1 == 0 print 1
n % 2 == 0 print 2
3, 4, 5, 6, 7, 8, 9 will not give remainder 0
exit loop;
The 1 and 2 which gives remainder as 0 it also mean that n is perfectly divisible by 1 and 2 so in second for loop keep printing the quotient on dividing by 1 and 2 which left remainder 0
from 10 to 1
keep checking n % 1 == 0 print n/1
n % 2 == 0 print n/2
exit loop05
n = 10
from 1 to 10
keep checking n % 1 == 0 print 1
n % 2 == 0 print 2
3, 4, 5, 6, 7, 8, 9 will not give remainder 0
exit loop;
The 1 and 2 which gives remainder as 0 it also mean that n is perfectly divisible by 1 and 2 so in second for loop keep printing the quotient on dividing by 1 and 2 which left remainder 0
from 10 to 1
keep checking n % 1 == 0 print n/1
n % 2 == 0 print n/2
exit loop62
The divisors of 100 are: 1 2 4 5 10 20 25 50 10015 n = 10
from 1 to 10
keep checking n % 1 == 0 print 1
n % 2 == 0 print 2
3, 4, 5, 6, 7, 8, 9 will not give remainder 0
exit loop;
The 1 and 2 which gives remainder as 0 it also mean that n is perfectly divisible by 1 and 2 so in second for loop keep printing the quotient on dividing by 1 and 2 which left remainder 0
from 10 to 1
keep checking n % 1 == 0 print n/1
n % 2 == 0 print n/2
exit loop19
n = 10
from 1 to 10
keep checking n % 1 == 0 print 1
n % 2 == 0 print 2
3, 4, 5, 6, 7, 8, 9 will not give remainder 0
exit loop;
The 1 and 2 which gives remainder as 0 it also mean that n is perfectly divisible by 1 and 2 so in second for loop keep printing the quotient on dividing by 1 and 2 which left remainder 0
from 10 to 1
keep checking n % 1 == 0 print n/1
n % 2 == 0 print n/2
exit loop9
The divisors of 100 are: 1 2 4 5 10 20 25 50 1000 n = 10
from 1 to 10
keep checking n % 1 == 0 print 1
n % 2 == 0 print 2
3, 4, 5, 6, 7, 8, 9 will not give remainder 0
exit loop;
The 1 and 2 which gives remainder as 0 it also mean that n is perfectly divisible by 1 and 2 so in second for loop keep printing the quotient on dividing by 1 and 2 which left remainder 0
from 10 to 1
keep checking n % 1 == 0 print n/1
n % 2 == 0 print n/2
exit loop13_______6_______14
n = 10
from 1 to 10
keep checking n % 1 == 0 print 1
n % 2 == 0 print 2
3, 4, 5, 6, 7, 8, 9 will not give remainder 0
exit loop;
The 1 and 2 which gives remainder as 0 it also mean that n is perfectly divisible by 1 and 2 so in second for loop keep printing the quotient on dividing by 1 and 2 which left remainder 0
from 10 to 1
keep checking n % 1 == 0 print n/1
n % 2 == 0 print n/2
exit loop00
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 10094 The divisors of 100 are: 1 2 4 5 10 20 25 50 10020 n = 10
from 1 to 10
keep checking n % 1 == 0 print 1
n % 2 == 0 print 2
3, 4, 5, 6, 7, 8, 9 will not give remainder 0
exit loop;
The 1 and 2 which gives remainder as 0 it also mean that n is perfectly divisible by 1 and 2 so in second for loop keep printing the quotient on dividing by 1 and 2 which left remainder 0
from 10 to 1
keep checking n % 1 == 0 print n/1
n % 2 == 0 print n/2
exit loop19
The divisors of 100 are: 1 2 4 5 10 20 25 50 1002_______6_______31 n = 10
from 1 to 10
keep checking n % 1 == 0 print 1
n % 2 == 0 print 2
3, 4, 5, 6, 7, 8, 9 will not give remainder 0
exit loop;
The 1 and 2 which gives remainder as 0 it also mean that n is perfectly divisible by 1 and 2 so in second for loop keep printing the quotient on dividing by 1 and 2 which left remainder 0
from 10 to 1
keep checking n % 1 == 0 print n/1
n % 2 == 0 print n/2
exit loop13
n = 10
from 1 to 10
keep checking n % 1 == 0 print 1
n % 2 == 0 print 2
3, 4, 5, 6, 7, 8, 9 will not give remainder 0
exit loop;
The 1 and 2 which gives remainder as 0 it also mean that n is perfectly divisible by 1 and 2 so in second for loop keep printing the quotient on dividing by 1 and 2 which left remainder 0
from 10 to 1
keep checking n % 1 == 0 print n/1
n % 2 == 0 print n/2
exit loop25
n = 10
from 1 to 10
keep checking n % 1 == 0 print 1
n % 2 == 0 print 2
3, 4, 5, 6, 7, 8, 9 will not give remainder 0
exit loop;
The 1 and 2 which gives remainder as 0 it also mean that n is perfectly divisible by 1 and 2 so in second for loop keep printing the quotient on dividing by 1 and 2 which left remainder 0
from 10 to 1
keep checking n % 1 == 0 print n/1
n % 2 == 0 print n/2
exit loop25 namespace59
The divisors of 100 are: 1 2 4 5 10 20 25 50 10094 n = 10
from 1 to 10
keep checking n % 1 == 0 print 1
n % 2 == 0 print 2
3, 4, 5, 6, 7, 8, 9 will not give remainder 0
exit loop;
The 1 and 2 which gives remainder as 0 it also mean that n is perfectly divisible by 1 and 2 so in second for loop keep printing the quotient on dividing by 1 and 2 which left remainder 0
from 10 to 1
keep checking n % 1 == 0 print n/1
n % 2 == 0 print n/2
exit loop34
n = 10
from 1 to 10
keep checking n % 1 == 0 print 1
n % 2 == 0 print 2
3, 4, 5, 6, 7, 8, 9 will not give remainder 0
exit loop;
The 1 and 2 which gives remainder as 0 it also mean that n is perfectly divisible by 1 and 2 so in second for loop keep printing the quotient on dividing by 1 and 2 which left remainder 0
from 10 to 1
keep checking n % 1 == 0 print n/1
n % 2 == 0 print n/2
exit loop35
n = 10
from 1 to 10
keep checking n % 1 == 0 print 1
n % 2 == 0 print 2
3, 4, 5, 6, 7, 8, 9 will not give remainder 0
exit loop;
The 1 and 2 which gives remainder as 0 it also mean that n is perfectly divisible by 1 and 2 so in second for loop keep printing the quotient on dividing by 1 and 2 which left remainder 0
from 10 to 1
keep checking n % 1 == 0 print n/1
n % 2 == 0 print n/2
exit loop31_______6_______4_______5_______76
n = 10
from 1 to 10
keep checking n % 1 == 0 print 1
n % 2 == 0 print 2
3, 4, 5, 6, 7, 8, 9 will not give remainder 0
exit loop;
The 1 and 2 which gives remainder as 0 it also mean that n is perfectly divisible by 1 and 2 so in second for loop keep printing the quotient on dividing by 1 and 2 which left remainder 0
from 10 to 1
keep checking n % 1 == 0 print n/1
n % 2 == 0 print n/2
exit loop35
The divisors of 100 are: 1 2 4 5 10 20 25 50 1002_______5_______80 n = 10
from 1 to 10
keep checking n % 1 == 0 print 1
n % 2 == 0 print 2
3, 4, 5, 6, 7, 8, 9 will not give remainder 0
exit loop;
The 1 and 2 which gives remainder as 0 it also mean that n is perfectly divisible by 1 and 2 so in second for loop keep printing the quotient on dividing by 1 and 2 which left remainder 0
from 10 to 1
keep checking n % 1 == 0 print n/1
n % 2 == 0 print n/2
exit loop35
C#
n = 10
from 1 to 10
keep checking n % 1 == 0 print 1
n % 2 == 0 print 2
3, 4, 5, 6, 7, 8, 9 will not give remainder 0
exit loop;
The 1 and 2 which gives remainder as 0 it also mean that n is perfectly divisible by 1 and 2 so in second for loop keep printing the quotient on dividing by 1 and 2 which left remainder 0
from 10 to 1
keep checking n % 1 == 0 print n/1
n % 2 == 0 print n/2
exit loop83
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_______6_______3_______6_______4 The divisors of 100 are: 1 2 4 5 10 20 25 50 1003 namespace93
The divisors of 100 are: 1 2 4 5 10 20 25 50 1006_______5_______5 n = 10
from 1 to 10
keep checking n % 1 == 0 print 1
n % 2 == 0 print 2
3, 4, 5, 6, 7, 8, 9 will not give remainder 0
exit loop;
The 1 and 2 which gives remainder as 0 it also mean that n is perfectly divisible by 1 and 2 so in second for loop keep printing the quotient on dividing by 1 and 2 which left remainder 0
from 10 to 1
keep checking n % 1 == 0 print n/1
n % 2 == 0 print n/2
exit loop9
The divisors of 100 are: 1 2 4 5 10 20 25 50 1000 // in sorted order30
The divisors of 100 are: 1 2 4 5 10 20 25 50 1002_______5_______23 n = 10
from 1 to 10
keep checking n % 1 == 0 print 1
n % 2 == 0 print 2
3, 4, 5, 6, 7, 8, 9 will not give remainder 0
exit loop;
The 1 and 2 which gives remainder as 0 it also mean that n is perfectly divisible by 1 and 2 so in second for loop keep printing the quotient on dividing by 1 and 2 which left remainder 0
from 10 to 1
keep checking n % 1 == 0 print n/1
n % 2 == 0 print n/2
exit loop34namespace1
The divisors of 100 are: 1 2 4 5 10 20 25 50 1006_______665_______5 The divisors of 100 are: 1 2 4 5 10 20 25 50 1006_______6_______3 n = 10
from 1 to 10
keep checking n % 1 == 0 print 1
n % 2 == 0 print 2
3, 4, 5, 6, 7, 8, 9 will not give remainder 0
exit loop;
The 1 and 2 which gives remainder as 0 it also mean that n is perfectly divisible by 1 and 2 so in second for loop keep printing the quotient on dividing by 1 and 2 which left remainder 0
from 10 to 1
keep checking n % 1 == 0 print n/1
n % 2 == 0 print n/2
exit loop4_______5_______3 std;09
The divisors of 100 are: 1 2 4 5 10 20 25 50 1003 std;11
The divisors of 100 are: 1 2 4 5 10 20 25 50 1006_______5_______5 n = 10
from 1 to 10
keep checking n % 1 == 0 print 1
n % 2 == 0 print 2
3, 4, 5, 6, 7, 8, 9 will not give remainder 0
exit loop;
The 1 and 2 which gives remainder as 0 it also mean that n is perfectly divisible by 1 and 2 so in second for loop keep printing the quotient on dividing by 1 and 2 which left remainder 0
from 10 to 1
keep checking n % 1 == 0 print n/1
n % 2 == 0 print n/2
exit loop9
The divisors of 100 are: 1 2 4 5 10 20 25 50 1000 // in sorted order30
The divisors of 100 are: 1 2 4 5 10 20 25 50 1002_______685_______18 n = 10
from 1 to 10
keep checking n % 1 == 0 print 1
n % 2 == 0 print 2
3, 4, 5, 6, 7, 8, 9 will not give remainder 0
exit loop;
The 1 and 2 which gives remainder as 0 it also mean that n is perfectly divisible by 1 and 2 so in second for loop keep printing the quotient on dividing by 1 and 2 which left remainder 0
from 10 to 1
keep checking n % 1 == 0 print n/1
n % 2 == 0 print n/2
exit loop34namespace1
The divisors of 100 are: 1 2 4 5 10 20 25 50 1006_______665_______5
The divisors of 100 are: 1 2 4 5 10 20 25 50 10068 std;7
The divisors of 100 are: 1 2 4 5 10 20 25 50 1001 std;29std;30 std;31
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_______5_______70 namespace0namespace1
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 1006_______677_______3
Javascript
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 10086 // in sorted order11
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_______6_______3 n = 10
from 1 to 10
keep checking n % 1 == 0 print 1
n % 2 == 0 print 2
3, 4, 5, 6, 7, 8, 9 will not give remainder 0
exit loop;
The 1 and 2 which gives remainder as 0 it also mean that n is perfectly divisible by 1 and 2 so in second for loop keep printing the quotient on dividing by 1 and 2 which left remainder 0
from 10 to 1
keep checking n % 1 == 0 print n/1
n % 2 == 0 print n/2
exit loop4std;53 std;54
n = 10
from 1 to 10
keep checking n % 1 == 0 print 1
n % 2 == 0 print 2
3, 4, 5, 6, 7, 8, 9 will not give remainder 0
exit loop;
The 1 and 2 which gives remainder as 0 it also mean that n is perfectly divisible by 1 and 2 so in second for loop keep printing the quotient on dividing by 1 and 2 which left remainder 0
from 10 to 1
keep checking n % 1 == 0 print n/1
n % 2 == 0 print n/2
exit loop9
The divisors of 100 are: 1 2 4 5 10 20 25 50 1000 // in sorted order30
The divisors of 100 are: 1 2 4 5 10 20 25 50 1002_______665_______39 n = 10
from 1 to 10
keep checking n % 1 == 0 print 1
n % 2 == 0 print 2
3, 4, 5, 6, 7, 8, 9 will not give remainder 0
exit loop;
The 1 and 2 which gives remainder as 0 it also mean that n is perfectly divisible by 1 and 2 so in second for loop keep printing the quotient on dividing by 1 and 2 which left remainder 0
from 10 to 1
keep checking n % 1 == 0 print n/1
n % 2 == 0 print n/2
exit loop34namespace1
The divisors of 100 are: 1 2 4 5 10 20 25 50 1006_______665_______5 The divisors of 100 are: 1 2 4 5 10 20 25 50 1006_______6_______3 n = 10
from 1 to 10
keep checking n % 1 == 0 print 1
n % 2 == 0 print 2
3, 4, 5, 6, 7, 8, 9 will not give remainder 0
exit loop;
The 1 and 2 which gives remainder as 0 it also mean that n is perfectly divisible by 1 and 2 so in second for loop keep printing the quotient on dividing by 1 and 2 which left remainder 0
from 10 to 1
keep checking n % 1 == 0 print n/1
n % 2 == 0 print n/2
exit loop4std;53 std;68
n = 10
from 1 to 10
keep checking n % 1 == 0 print 1
n % 2 == 0 print 2
3, 4, 5, 6, 7, 8, 9 will not give remainder 0
exit loop;
The 1 and 2 which gives remainder as 0 it also mean that n is perfectly divisible by 1 and 2 so in second for loop keep printing the quotient on dividing by 1 and 2 which left remainder 0
from 10 to 1
keep checking n % 1 == 0 print n/1
n % 2 == 0 print n/2
exit loop9
The divisors of 100 are: 1 2 4 5 10 20 25 50 1000 // in sorted order30
The divisors of 100 are: 1 2 4 5 10 20 25 50 1002_______665_______79 n = 10
from 1 to 10
keep checking n % 1 == 0 print 1
n % 2 == 0 print 2
3, 4, 5, 6, 7, 8, 9 will not give remainder 0
exit loop;
The 1 and 2 which gives remainder as 0 it also mean that n is perfectly divisible by 1 and 2 so in second for loop keep printing the quotient on dividing by 1 and 2 which left remainder 0
from 10 to 1
keep checking n % 1 == 0 print n/1
n % 2 == 0 print n/2
exit loop34 std;75
The divisors of 100 are: 1 2 4 5 10 20 25 50 1006_______665_______5
The divisors of 100 are: 1 2 4 5 10 20 25 50 1006_______665_______79 namespace0namespace1
The divisors of 100 are: 1 2 4 5 10 20 25 50 1006_______677_______3 The divisors of 100 are: 1 2 4 5 10 20 25 50 1006
Đầu ra The divisors of 100 are: 1 2 4 5 10 20 25 50 100 Độ phức tạp về thời gian. O(sqrt(n)) Không gian phụ trợ. Ô(1) Điều kiện if giữa hai vòng lặp được sử dụng khi các thừa số góc trong điều kiện của vòng lặp có chênh lệch bằng 1 (ví dụ: thừa số 30 (5,6) ở đây, 5 sẽ được in hai lần; để giải quyết vấn đề đó, bước này là bắt buộc Bài viết này được đóng góp bởi Ashutosh Kumar. Vui lòng viết nhận xét nếu bạn thấy bất cứ điều gì không chính xác hoặc nếu bạn muốn chia sẻ thêm thông tin về chủ đề đã thảo luận ở trên |
