Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

We need to write 3 small functions on list operations both provided by the standard library and useful utility functions. Language to be used -

We need to write 3 small functions on list operations both provided by the standard library and useful utility functions.

Language to be used - F#

Urgent help, will give thumbs up and good feedback, thank you!

image text in transcribed

image text in transcribed

image text in transcribed

Exercise #14: GCDList L The function GCDList calculates the greatest common divisor of a list of positive integers. You can assume there are at least two integers in the list. You might find the GCD function helpful. The GCD function should be written in the Project02-14.fs file. // // GCDList L // // Returns the greatest common divisor of a list of positive integers // // Examples: // GCDList [5;10] => 5 // GCDList [54; 24] => 6 // GCDList [341341341; 341341; 341; 2013; 1234321] => 11 // Exercise #15: is Prime i The function is Prime tests whether a number is prime. A number is prime if it satisfies two conditions: 1. The number is an integer greater than 1 (natural number excluding 1). 2. The number n has only two integral solutions to the equation n = a*b; a=n and b=1 OR a=1 and b=n. Alternative definitions you may find useful: The number is not formed as a product of two smaller natural numbers. The number has a GCD of 1 with all natural numbers smaller than it. It returns true if the input is a prime number, and false otherwise. The is Prime function should be written in the Project02-15.fs file. // // isprime i // returns true if and only if i is prime Page 7 of 9 // Examples: isPrime 1 => false isPrime 2 => true isPrime 4 => false // isPrime 7919 => true isPrime 57714373 => false Exercise #16: Primest The function Primes takes a positive integer t as input, returns all the primes from 1 to t (including t), in ascending order. You might find the is Prime function or the Sieve of Eratosthenes algorithm helpful. The isPrime function should be written in the Project02-16.fs file. // // Primest // returns all the primes from 1 to t in a list, in ascending order. // // Examples: // Primes 1 => [] // Primes 2 => [2] // Primes 4 => [2;3] // Primes 11 => [2; 3; 5; 7;11] // Exercise #14: GCDList L The function GCDList calculates the greatest common divisor of a list of positive integers. You can assume there are at least two integers in the list. You might find the GCD function helpful. The GCD function should be written in the Project02-14.fs file. // // GCDList L // // Returns the greatest common divisor of a list of positive integers // // Examples: // GCDList [5;10] => 5 // GCDList [54; 24] => 6 // GCDList [341341341; 341341; 341; 2013; 1234321] => 11 // Exercise #15: is Prime i The function is Prime tests whether a number is prime. A number is prime if it satisfies two conditions: 1. The number is an integer greater than 1 (natural number excluding 1). 2. The number n has only two integral solutions to the equation n = a*b; a=n and b=1 OR a=1 and b=n. Alternative definitions you may find useful: The number is not formed as a product of two smaller natural numbers. The number has a GCD of 1 with all natural numbers smaller than it. It returns true if the input is a prime number, and false otherwise. The is Prime function should be written in the Project02-15.fs file. // // isprime i // returns true if and only if i is prime Page 7 of 9 // Examples: isPrime 1 => false isPrime 2 => true isPrime 4 => false // isPrime 7919 => true isPrime 57714373 => false Exercise #16: Primest The function Primes takes a positive integer t as input, returns all the primes from 1 to t (including t), in ascending order. You might find the is Prime function or the Sieve of Eratosthenes algorithm helpful. The isPrime function should be written in the Project02-16.fs file. // // Primest // returns all the primes from 1 to t in a list, in ascending order. // // Examples: // Primes 1 => [] // Primes 2 => [2] // Primes 4 => [2;3] // Primes 11 => [2; 3; 5; 7;11] //

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Database Design And Relational Theory Normal Forms And All That Jazz

Authors: Chris Date

1st Edition

1449328016, 978-1449328016

More Books

Students also viewed these Databases questions

Question

Explain the function and purpose of the Job Level Table.

Answered: 1 week ago