Answered step by step
Verified Expert Solution
Question
1 Approved Answer
Must use functions and can not hardcode the fibonacci sequence. Function 1 : Fibonacci Numbers Background The Fibonacci numbers are a sequence of numbers where
Must use functions and can not hardcode the fibonacci sequence.
Function : Fibonacci Numbers
Background
The Fibonacci numbers are a sequence of numbers where each number is the sum of the two numbers that appear before it The sequence starts with and The first numbers are as follows:
Assignment
Your task is to define a function named "fibonace" that takes an integer and returns the Fibonacci number at that position in the sequence. The number in the first position is You can assume that the parameters to the function will be positive integers. You may not use a direct mathematical formula to find the Nth Fibonacci number.
Examples
You can test your function's correctness by checking that all the cases below are true:
fibonacci
fibonacci
fibonacci
fibonacci
fibonacci
Function : Prime Numbers
Background
A prime number is an integer greater than one that is only divisible by and itself. You can check if is divisible by with the statement Examples of prime numbers are and
Examples of nonprime numbers are and and are divisible by and are divisible by
Assignment
Your task is to define a function named isprime" that takes an integer as a parameter and returns True if the number is prime, and False if the number is not prime. You can assume that the parameters to the function will be integers, but they may be negative.
Examples
You can test your function's correctness by checking that all the cases below are true:
isprime True
isprime True
isprime True
isprime False
isprime False
isprime False
Function : Prime Factorization
Background
All positive integers greater than can be expressed as the product of a unique combination of prime numbers. This combination of prime numbers is referred to as the number's prime factorization. For example, the number can be expressed as The prime factorization for a prime number is just itself.
Assignment
Your assignment is to write a function named "printprimefactors" that will take an integer as its parameter and calculate the integer's prime factorization. While the first two functions returned their results, this function will instead print the result and return nothing. The output should be in the format parameter factor factor factor Note that a prime may appear more than once in the prime factorization, and the factors should be printed in order of least to greatest.
Examples
Here is a sample program for testing your function:
printprimefactors
printprimefactors
printprimefactors
printprimefactors
printprimefactors
This should print out the following:
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started