Question: Overview In this lab students will build three functions. The first function will calculate the nth Fibonacol number. The second function will check whether a
Overview
In this lab students will build three functions. The first function will calculate the nth Fibonacol number. The second function will check whether a given number is prime. The third function will print the prime factors of a given number. The lab is designed to give students an opportunity to experiment with writing functions while practicing loops and conditionals.
Submission
Your submission should be a single file containing all functions and no other code. The file name should be your initials, followed by Labpy For example, "axaLabpy
Specification
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
1 Expert Approved Answer
Step: 1 Unlock
Question Has Been Solved by an Expert!
Get step-by-step solutions from verified subject matter experts
Step: 2 Unlock
Step: 3 Unlock
