Divisors of a number

Beginner Problems Basic Maths Easy
  • Fun Fact: The underlying concept from this problem, finding all the divisors of a number, is surprisingly important in cryptography, a critical part of information security
  • Specifically, it's used in the RSA encryption algorithm, which is widely implemented in communication protocols like HTTPS for secure data transmission over the internet
  • The algorithm uses two large prime numbers, whose product serves as a key
  • The security of RSA is based on the fact that, even knowing the product, it's difficult to determine the original primes (i
  • e
  • , find the divisors), particularly as the prime numbers used become larger

You are given an integer n. You need to find all the divisors of n. Return all the divisors of n as an array or list in a sorted order.


A number which completely divides another number is called it's divisor.

Examples:

Input: n = 6

Output = [1, 2, 3, 6]

Explanation: The divisors of 6 are 1, 2, 3, 6.

Input: n = 8

Output: [1, 2, 4, 8]

Explanation: The divisors of 8 are 1, 2, 4, 8.

Input: n = 7

Constraints

  • 1 <= n <= 1000

Company Tags

TCS Cognizant Accenture Infosys Capgemini Wipro IBM HCL Tech Mahindra MindTree