Friendly Numbers
Function Name: isFriendly
Description
Write a function 'isFriendly' that determines if two numbers are friendly numbers. Friendly numbers are two or more numbers with a common abundancy, which means that the sum of the proper divisors (excluding the number itself) of each number divided by the number itself is equal for both numbers. The function should take two integer parameters and return a boolean value - true if the numbers are friendly, false otherwise.
Requirements
- The function must accept two integer parameters.
- The function should return a boolean value.
- You should find proper divisors for each number efficiently, avoiding unnecessary computation.
- The maximum value for each parameter should not exceed 10000 to ensure reasonable performance.
- Assuming inputs are always positive integers greater than 1.
Examples
Example 1: isFriendly(220, 284) should return true.Example 2: isFriendly(10, 20) should return false.Example 3: isFriendly(1184, 1210) should return true.
Links
Simple Time Conversion
Sun Sep 08 2024
Write a function that converts 12-hour time format to 24-hour format.The function should be able to distinguish between AM and PM to convert the time accurately.Ignore the possibility of invalid time inputs and focus on the conversion logic.The input time will be a string in the format 'hh:mm AM' or 'hh:mm PM'.The output should be a string in the format 'HH:mm', where 'HH' is the hour in 24-hour format.
Pascal's Triangle Generator
Tue Sep 10 2024
Write a function named 'generatePascalsTriangle' that generates and returns Pascal's triangle up to the 'n-th' level.Pascal's triangle is a triangular array of the binomial coefficients. Each number is the sum of the two numbers directly above it.The function should take one integer 'n' as a parameter, which represents the number of levels in the triangle.The function should return a list of lists, where each inner list represents a level of the triangle.