Define in Scheme an infinite stream consisting of all pairs of twin prime numbers, i.e. all pairs of prime numbers differing by 2, listed in increasing order according to the first number of a pair, in every pair the first item being smaller than the second item. Hint: Apply the sieve of Eratosthenes in order to construct a predicate is-prime?
In the given question, an infinite stream consist of two pair. Suppose infinite stream is n. Then we have to find out the pair of all two prime numbers that 1 to n. So the prime number like 3, 5, 7. All the prime numbers difference will be 2 and first number will be smaller than the second number like pair would be (3, 5)(5, 7)(11,13) and so on. So (2,3) is not accepted here because of distance is 1.
Solution of the problem in scheme:
Example:
Input: 35.
Output :(3, 5), (5, 7), (11, 13), (17, 19) (29, 31).
Other example:
Input : nth numbers.
Output:(3, 5), (5, 7), (11, 13)........(n-2, n).
*Please give an upvote if you find this solution helpful.
Define in Scheme an infinite stream consisting of all pairs of twin prime numbers, i.e. all...
Define in Scheme an infinite stream consisting of twin prime numbers. All primes ? with the property that ? + 2 or ? − 2 are also prime should be included, each one only once. Hint: Apply the Sieve of Eratosthenes.
Scheme Language: Define a function nondecreastream, which takes in a stream of numbers and outputs a stream of lists, which overall has the same numbers in the same order, but grouped into segments that are non-decreasing. For example, if the input is a stream containing elements 1 2 3 4 1 2 3 4 1 1 1 2 1 1 0 4 3 2 1 ... the output should contain elements (1 2 3 4) (1 2 3 4) (1...
Program Requirements First, find all the prime numbers between 2 and a user-inputted number from the console (inclusive). The identified prime numbers must be stored in an array . The inputted number should be between 0 and 1000 (inclusive). array is large enough to o Make sure your hold all the prim e numbers. Dynamic memory allocation is not required for this assignment, so you can have unused space in your array Make sure you can handle the cases of...
PLEASE HELP! python code Problem 4. Define the function pythagorian_coprimes (n=100) that prints all pairs of positive integer numbers (a, b) such that c = a + b is also a whole number and 1 <c<n. Include only those triples that are co-prime (do not have any common divisors other than 1). For example, (3, 4, 5) is okay but (30, 40, 50) should be skipped. Help: As a starting example, examine the function pythagorian_triples that yields all triples. Modify...
please answer all of my multiple choice Q's without a proof. Thank you. 10 Homework Assignments Homework 4 Match the numbers with the description 1 9 ✓ Choose... Prime A power of prime Composite and not a power of prime Neither prime nor composite 11 12 Choose... Which of these equations is produced as a step when the Euclidean algorithm is used to find the god of 165 and 346? Select one or more: a. 5 = 5·1+0 b. 346...
A) in minutes B) in launched pairs C) in rad/s All of the questions on this exam concern a space station, consisting of a long thin uniform rod of mass identical uniform hollow spheres, each of mass D E 74-meters, attached at the ends of the rod, as shown below. Note that none of the diograms shown is drawn to scale 4 4x 10° kg and length C. 4.4 x10 kg and l length C.240 meters, with two 17-'x 106kg...
Mountain Paths (Part 1) in C++ Objectives 2d arrays Store Use Nested Loops Parallel data structures (i.e. parallel arrays … called multiple arrays in the zyBook) Transform data Read from files Write to files structs Code Requirements Start with this code: mtnpathstart.zip Do not modify the function signatures provided. Do not #include or #include Program Flow Read the data into a 2D array Find min and max elevation to correspond to darkest and brightest color, respectively Compute the shade of...
1 L, as a dynamical system (Notes from Assignment #2) We take our definition of dynamical system to be an "object" along with a specific set of modifications that can be performed (dynamically) upon this object. In this case, the object is a bi-infinite straight road with a lamp post at every street corner and a marked lamp (the position of the lamplighter). There are two possible types of modifications: the lamplighter can walk any distance in either direction from...
Need help, numbers 3-6 please show work. and fill out table of chemicals for all chemical used. calculate mmol in the table as well show work please and each of these must be listed in its own row. There are 10 column headings: IUPAC name OR common name, structure, CAS number (Chemical Abstract Service number) molecular mass, melting point (if applicable), boiling point (if applicable), solubility (in water, if applicable), density, amounts to be used in the experiment, and the...
This C++ Program consists of: operator overloading, as well as experience with managing dynamic memory allocation inside a class. Task One common limitation of programming languages is that the built-in types are limited to smaller finite ranges of storage. For instance, the built-in int type in C++ is 4 bytes in most systems today, allowing for about 4 billion different numbers. The regular int splits this range between positive and negative numbers, but even an unsigned int (assuming 4 bytes)...