Find N-th Term of Series a, b, b, c, c, c in C++

Ayush Gupta
Updated on 09-Oct-2020 07:03:01

368 Views

In this problem, we are given a number N. Our task is to create a Program to find N-th term of series a, b, b, c, c, c…in C++.Problem DescriptionTo find the Nth term of the series −a, b, b, c, c, c, d, d, d, d, ....Nterms We need to find the general term of the series.Let’s take an example to understand the problem, InputN = 7OutputdSolution ApproachTo find the general term of the series, we need to closely observe the series. The series has 1 a, 2 b’s, 3 c’s, 4 d’s, ... This seems to be an AP. ... Read More

Find N-th Term in Given Series using C++

Ayush Gupta
Updated on 09-Oct-2020 06:57:04

291 Views

In this problem, we are given a number N. Our task is to create a program to find N-th term in the given series in C++.Problem DescriptionTo find the sum of the given series −1, 1, 2, 3, 4, 9, 8, 27, 16, 81, 32, 243, 64, 729, 128, 2187, 256, ... NTermsWe will find the general term of the series.Let’s take an example to understand the problem, Example 1InputN = 6Output9Example 2InputN = 13Output64Solution ApproachTo solve the problem, we need to carefully observe the series. As it is, a mixture series and these types of series are difficult to ... Read More

Find Nth Term Divisible by A or B in C++

Ayush Gupta
Updated on 09-Oct-2020 06:45:31

737 Views

In this problem, we are given three numbers A, B, and N. Our task is to create a program to find Nth term divisible by A or B in C++.Problem DescriptionThe Nth Term divisible by A or B. Here, we will find the term n number term which is divisible by number A or B. For this, we will count till nth numbers that are divisible by A or B.Let’s take an example to understand the problem, InputA = 4, B = 3, N = 5Output9ExplanationThe terms the are divisible by 3 and 4 are −3, 4, 6, 8, 9, ... Read More

Find N-th Term of Series 0, 0, 2, 1, 4, 2, 6, 3, 8 in C++

Ayush Gupta
Updated on 09-Oct-2020 06:38:22

243 Views

In this problem, we are given a number N. Our task is to create a program to find N-th term of series 0, 0, 2, 1, 4, 2, 6, 3, 8…in C++.Problem descriptionTo find the Nth term of the given series−0, 0, 2, 1, 4, 2, 6, 3, 8 .... N TermsWe will find the general term of the series.Let’s take an example to understand the problem, InputN = 8Output3Solution ApproachTo find the general term of the series, we need to closely observe the series. This series is a bit difficult to recognize as it is a mixture of two ... Read More

Create Transparent Histogram Using ggplot2 in R

Nizamuddin Siddiqui
Updated on 08-Oct-2020 15:23:20

3K+ Views

When we create a histogram using ggplot2 package, the area covered by the histogram is filled with grey color but we can remove that color to make the histogram look transparent. This can be done by using fill="transparent" and color="black" arguments in geom_histogram, we need to use color argument because if we don’t use then the borders of the histogram bars will also be removed and this color is not restricted to black color only.ExampleConsider the below data frame −set.seed(987) x

Select Values Based on Percentile from R Data Frame Column

Nizamuddin Siddiqui
Updated on 08-Oct-2020 15:21:21

709 Views

The percentiles divide a set of numeric values into hundred groups or individual values if the size of the values is 100. We can find percentiles for a numeric column of an R data frame, therefore, it is also possible to select values of a column based on these percentiles. For this purpose, we can use quantile function.ExampleConsider the below data frame −set.seed(111) x

Convert Integers to Words in R

Nizamuddin Siddiqui
Updated on 08-Oct-2020 15:17:25

119 Views

If we have numbers then we might want to convert those numbers into words. For example, converting 1 to one. This might be required in cases where we have text data and numbers are part of the text. Therefore, it would be better to represent the numbers in text form to make the uniformity in the text. This can be done by using replace_number function qdap package.Installing and loading qdap package−install.packages("qdap") library("qdap")Examplereplace_number("1") [1] "one" replace_number("10") [1] "ten" replace_number("100") [1] "one hundred" replace_number("1000") [1] "one thousand" replace_number("1001") [1] "one thousand one" replace_number("12000") [1] "twelve thousand" replace_number("12214") [1] "twelve thousand two hundred ... Read More

Set NA Values to True for a Boolean Column in R Data Frame

Nizamuddin Siddiqui
Updated on 08-Oct-2020 15:14:58

962 Views

Dealing with NA values is one of the boring and almost day to day task for an analyst and hence we need to replace it with the appropriate value. If in an R data frame, we have a Boolean column that represents TRUE and FALSE values, and we have only FALSE values then we might want to replace NA’s with TRUE. In this case, we can use single square bracket and is.na to set all NA’s to TRUE.Exampleset.seed(999) S.No.

Fill NA Values from Above Row in R Data Frame

Nizamuddin Siddiqui
Updated on 08-Oct-2020 15:06:47

957 Views

Sometimes we have missing values that can be replaced with the values on the above row values, it often happens in situations when the data is recorded manually and the person responsible for it just mention the unique values because he or she understand the data characteristics. But if this data needs to be re-used by someone else then it does not make sense and we have to connect with the concerned person. If the concerned person tells us that the first value in each row can be filled for every NA in the same column then it can be ... Read More

Represent Mean with Vertical Line in Histogram using hist() Function in R

Nizamuddin Siddiqui
Updated on 08-Oct-2020 15:02:41

2K+ Views

The value of mean is an important characteristic of the data to be represented by a histogram, therefore, one might want to plot it with the histogram. If the histogram is created by using hist function then we can create a vertical line on the histogram with the help of abline function by defining mean of the data for vertical argument v.Exampleset.seed(101) x

Advertisements