Manafall Daily Quest

Prime Factorization

Function Name: primeFactorize

Description

The task is to write a function named 'primeFactorize that takes a single integer parameter and returns an array or list of its prime factors (including multiplicity).

A prime factor is a factor that is a prime number, and prime factorization of a number is a list of prime numbers that multiply to the number.

The function should handle erroneous and edge cases gracefully, such as negative inputs, zero, and one, by returning an empty list or array.

Requirements

  • The function should accept a single integer ('n') as its parameter.
  • It should return an array or list of integers, which represent the prime factors of 'n'.
  • If 'n' is less than 2, return an empty list or array.
  • The prime factors should be in ascending order.

Examples

For 'primeFactorize(28)', the function should return [2, 2, 7].For 'primeFactorize(5)', the function should return [5].For 'primeFactorize(-10)', the function should return [].

Links

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

Unique Character Mapping

Wed Jul 31 2024

Write a function called `uniqueCharMap` which takes a single string as its parameter.The function should return a map (or dictionary) where each key is a unique character from the string, and the value is the number of times that character appears in the string.The function should ignore case, treating uppercase and lowercase characters as the same.The result should be sorted by the keys in alphabetical order.Non-letter characters should be included.Spaces should be counted and mapped as well.If the input string is empty, the function should return an empty map.

Prev Quest

Recursive Fibonacci Finder

Fri Aug 02 2024

Write a function that computes the nth Fibonacci number. The Fibonacci sequence is characterized by the fact that every number after the first two is the sum of the two preceding ones. This function should use recursion to calculate the Fibonacci number. By definition, the first two numbers in the Fibonacci sequence are 0 and 1, and each subsequent number is the sum of the previous two.

Next Quest