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 divisors 0// A O(sqrt(n)) program that prints all divisors 1The 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 divisors 0// A O(sqrt(n)) program that prints all divisors 1
The divisors of 100 are: 1 2 4 5 10 20 25 50 1007 // in sorted order 1The divisors of 100 are: 1 2 4 5 10 20 25 50 1007 // in sorted order 3The 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 order 5The 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 6n = 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 divisors 0using 1
The divisors of 100 are: 1 2 4 5 10 20 25 50 1003 using 5The 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 loop4 namespace 0namespace 1The 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 namespace 6
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 divisors 0// A O(sqrt(n)) program that prints all divisors 1The divisors of 100 are: 1 2 4 5 10 20 25 50 1007 // A O(sqrt(n)) program that prints all divisors 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 10027 The divisors of 100 are: 1 2 4 5 10 20 25 50 10028 // A O(sqrt(n)) program that prints all divisors 0// A O(sqrt(n)) program that prints all divisors 1
The divisors of 100 are: 1 2 4 5 10 20 25 50 10027 // in sorted order 1The 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 order 5The 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 order 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 #include 1n = 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 divisors 0The 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 namespace 1n = 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 namespace 1The divisors of 100 are: 1 2 4 5 10 20 25 50 1006_______665_______5
Python3The 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 loop34 namespace 1The divisors of 100 are: 1 2 4 5 10 20 25 50 1007 // A O(sqrt(n)) program that prints all divisors 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 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 loop34 namespace 1
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 order 5The 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 order 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 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 loop34 namespace 1The 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 namespace 0namespace 1n = 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 namespace 3The 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 PHPThe 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 divisors 00The 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 divisors 04 // A O(sqrt(n)) program that prints all divisors 05
The divisors of 100 are: 1 2 4 5 10 20 25 50 10088 namespace 1// A O(sqrt(n)) program that prints all divisors 04// A O(sqrt(n)) program that prints all divisors 12The 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 divisors 04 // A O(sqrt(n)) program that prints all divisors 21n = 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 divisors 28_______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 divisors 04 // A O(sqrt(n)) program that prints all divisors 32// A O(sqrt(n)) program that prints all divisors 04n = 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 divisors 36 // A O(sqrt(n)) program that prints all divisors 04 // A O(sqrt(n)) program that prints all divisors 38n = 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 divisors 36 // A O(sqrt(n)) program that prints all divisors 04 // A O(sqrt(n)) program that prints all divisors 38n = 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 divisors 52The divisors of 100 are: 1 2 4 5 10 20 25 50 1007 // A O(sqrt(n)) program that prints all divisors 54The 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 divisors 57The divisors of 100 are: 1 2 4 5 10 20 25 50 10099 // A O(sqrt(n)) program that prints all divisors 59The 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 divisors 04The 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 order 5The 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 divisors 04 The divisors of 100 are: 1 2 4 5 10 20 25 50 10094 // A O(sqrt(n)) program that prints all divisors 79n = 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 divisors 82
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 divisors 36 The divisors of 100 are: 1 2 4 5 10 20 25 50 10096 // A O(sqrt(n)) program that prints all divisors 57// A O(sqrt(n)) program that prints all divisors 04// A O(sqrt(n)) program that prints all divisors 93n = 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 order 11The 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 order 23
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 order 30n = 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 order 37The divisors of 100 are: 1 2 4 5 10 20 25 50 1007 // in sorted order 39n = 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 namespace 1The 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 order 39n = 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 namespace 1
The divisors of 100 are: 1 2 4 5 10 20 25 50 1007 // A O(sqrt(n)) program that prints all divisors 52The divisors of 100 are: 1 2 4 5 10 20 25 50 1007 // A O(sqrt(n)) program that prints all divisors 54The divisors of 100 are: 1 2 4 5 10 20 25 50 1007 // in sorted order 55The 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 order 5The 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 order 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 loop34 namespace 1The 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 00The divisors of 100 are: 1 2 4 5 10 20 25 50 1006_______6_______3 #include 03n = 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 order 30The 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 15n = 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 17The 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 22n = 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 order 30The 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 using 5The 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 namespace 0The 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 namespace 6
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 00The divisors of 100 are: 1 2 4 5 10 20 25 50 1006_______6_______3 #include 62n = 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 order 30The 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 divisors 0_______660_______1The 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 22n = 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 order 30The 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 divisors 0_______670_______92The 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 using 5The 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 loop4 namespace 0namespace 1The 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 namespace 6
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 00The 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 using 32The 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 namespace 1The 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 using 48The 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 loop34 namespace 1The 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 using 80The 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 namespace 1The 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 namespace 1
Python3
The divisors of 100 are: 1 2 4 5 10 20 25 50 10088 std; 0 using 99
The divisors of 100 are: 1 2 4 5 10 20 25 50 10090 namespace 02
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 namespace 09using 99 namespace 11n = 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 namespace 39_______5_______20n = 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 namespace 59The 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 namespace 93The 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 order 30The 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 loop34 namespace 1The 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; 09The divisors of 100 are: 1 2 4 5 10 20 25 50 1003 std; 11The 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 order 30The 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 loop34 namespace 1The 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; 31The 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 namespace 0namespace 1The 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 order 11The 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 loop4 std; 53 std; 54n = 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 order 30The 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 loop34 namespace 1The 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 std; 53 std; 68n = 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 order 30The 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; 75The 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 namespace 0namespace 1The 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 |