Using the functional programming language RACKET solve the following problem: The prime-factors function takes an integer n as input (n į 0) and returns a list containing the prime factors of n in ascending order. Prime factors are the prime numbers that divide a number exactly. If all the prime factors are multiplied, the original number is obtained.

C++ Programming: From Problem Analysis to Program Design
8th Edition
ISBN:9781337102087
Author:D. S. Malik
Publisher:D. S. Malik
Chapter15: Recursion
Section: Chapter Questions
Problem 8SA
icon
Related questions
Question

3

Using the functional programming language RACKET solve the following problem:
The prime-factors function takes an integer n as input (n i 0) and returns a list
containing the prime factors of n in ascending order. Prime factors are the prime
numbers that divide a number exactly. If all the prime factors are multiplied, the original
number is obtained.
Examples:
(prime-factors 1)
» ()
(prime-factors 6)
+ (2 3)
(prime-factors 96)
→ (2 2 2 2 2 3)
(prime-factors 97)
+ (97)
(prime-factors 666)
+ (2 3 3 37)
Transcribed Image Text:Using the functional programming language RACKET solve the following problem: The prime-factors function takes an integer n as input (n i 0) and returns a list containing the prime factors of n in ascending order. Prime factors are the prime numbers that divide a number exactly. If all the prime factors are multiplied, the original number is obtained. Examples: (prime-factors 1) » () (prime-factors 6) + (2 3) (prime-factors 96) → (2 2 2 2 2 3) (prime-factors 97) + (97) (prime-factors 666) + (2 3 3 37)
Expert Solution
steps

Step by step

Solved in 2 steps

Blurred answer
Knowledge Booster
Topological Sort
Learn more about
Need a deep-dive on the concept behind this application? Look no further. Learn more about this topic, computer-science and related others by exploring similar questions and additional content below.
Similar questions
  • SEE MORE QUESTIONS
Recommended textbooks for you
C++ Programming: From Problem Analysis to Program…
C++ Programming: From Problem Analysis to Program…
Computer Science
ISBN:
9781337102087
Author:
D. S. Malik
Publisher:
Cengage Learning