Manafall Daily Quest

Prime Factorization

Function Name: calculatePrimeFactors

Description

In this challenge, you are to write a function named calculatePrimeFactors that takes an integer greater than 1 as a parameter and returns a list of its prime factors.

Prime factors are the prime numbers that multiply together to equal the original number.

The function should return the prime factors in ascending order.

Requirements

  • The function must take one parameter: an integer greater than 1.
  • The function must return an array or list containing the prime factors of the input integer, sorted in ascending order.
  • The function must handle input integers up to at least 10,000.
  • Optimize the function for performance.

Examples

If the input integer is 60, the function should return [2, 2, 3, 5].If the input integer is 13, the function should return [13], since 13 is a prime number.

Links

https://en.wikipedia.org/wiki/Prime_numberhttps://en.wikipedia.org/wiki/Prime_factor

Subarray with Given Sum

Sun Sep 15 2024

Write a function that finds a contiguous subarray within a one-dimensional array of positive integers which adds up to a given sum.The function should return the indices of the first and last elements in the subarray that adds up to the specified sum, or indicate that no such subarray exists.The array and sum will be passed as parameters to the function.If there are multiple such subarrays, the function should return the indices of the subarray with the smallest starting index.

Prev Quest

Tree Level Sums

Tue Sep 17 2024

Write a function that calculates the sum of values at each level of a binary tree.The function should take the root of the binary tree as an input parameter.The binary tree nodes have an integer value, along with left and right child pointers.The function should return an array, where each element represents the sum of the values at the corresponding level of the tree.Level order traversal of the tree would help to collect the sums in breadth-first manner.

Next Quest