Write some r code that carries out computation but do it


1. In his book, Professor Stewart's Hoard of Mathematical Treasures, Ian Stewart asks readers to compute the following expressions.

(8 x 8) + 13
(8 x 88) + 13
(8 x 888) + 13
(8 x 8888) + 13
(8 x 88888) + 13
(8 x 888888) + 13
(8 x 8888888) + 13
(8 x 88888888) + 13

Write some R code that carries out this computation, but do it with a single R expression that contains no commas (,) and no braces ({}).

Hints: This exercise is about computations with vectors. You can do it with sequence generation, simple arithmetic and application of summaries.

2. A Pythagorean triple consists of three positive integers a, b and c with a2 + b2 = c2. Without using control flow constructs (if, for, while and repeat), use R to list all Pythagorean triples with a, b and c less than 1000 and a < b < c (there are 881 such triples).

Hints: Positive integers, a and b, will be part of a triple whenever the square root of a2 + b2 is an integer. You will need try all combinations of a and b less than or equal to 1000 and check whether a < b and that √a2 + b2 is an integer less than or equal to 1000. Sequence generation, repetition and subsetting may prove useful.

3. Some digits look (nearly) the same when turned upside-down (0, 1, 8). Two more come in a pair, each being the other turned upside down (6, 9). The rest (2, 3, 4, 5, 7) don't look like digits when turned upside down.

Some years look the same when turned upside-down. For example, 1691 is unchanged if turned upside down. (Note that turning a year upside down means turning the digits upside down and reverseing their order.)

Solution Preview :

Prepared by a verified Expert
Programming Languages: Write some r code that carries out computation but do it
Reference No:- TGS0572097

Now Priced at $30 (50% Discount)

Recommended (95%)

Rated (4.7/5)