Find N Variables from N Sum Equations with One Missing in C++

sudhir sharma
Updated on 13-Mar-2021 12:27:57

117 Views

In this problem, we are given an array sum[] consisting of a sum of (n-1) variables given as, Sum[1] = x2 + x3 + x4 + … xn Sum[2] = x1 + x3 + x4 + … xn . . Sum[i] = x2 + x3 + x4 + … x(i-1) + x(i+1) + … + xn . . Sum[n] = x1 + x2 + x3 + … x(n-1) Our task is to find the value of x1, x2, ... xn.Let’s take an example to understand the problem, Inputsum[] = {6, 6, 6, 6, 6, 6, 6}Outputx1 = 1, x2 = ... Read More

Find N-th Term of Series 3, 9, 21, 41, 71 in C++

sudhir sharma
Updated on 13-Mar-2021 12:26:14

291 Views

In this problem, we are given an integer N. The task is to find the n-th term in series 3, 9, 21, 41, 71...Let’s take an example to understand the problem, InputN = 7Output169ExplanationThe series is 3, 9, 21, 41, 71, 169...Solution ApproachA simple solution to the problem is by finding the general term of the series. The general term can be found by observing the series a bit. It is, $$T(N) = \sum n^{2} + \sum n + 1$$We can directly use the formula for the sum of square of first n natural numbers, first n natural number and ... Read More

Find N-th Term of Series 2, 10, 30, 68, 130 in C++

sudhir sharma
Updated on 13-Mar-2021 12:24:30

3K+ Views

In this problem, we are given an integer N. The task is to find the n-th term in series 2, 10, 30, 68, 130...Let’s take an example to understand the problem, InputN = 7Output350ExplanationThe series is 2, 10, 30, 68, 130, 222, 350...Solution ApproachA simple solution to the problem is by finding the general term of the series. Here, the Nth term of the series is N^3 + N. This is found by subtracting the current element with the current index.For i, i = 1, T(1) = 2 = 1 + 1 = 1^3 + 1 i = 2, T(1) ... Read More

Find N-th Term of Series 1, 3, 6, 10, 15, 21 in C++

sudhir sharma
Updated on 13-Mar-2021 12:22:37

657 Views

In this problem, we are given an integer N. The task is to find the n-th term in series 1, 3, 6, 10, 15, 21, 28....Let’s take an example to understand the problem, InputN = 7Output28ExplanationThe series is 1, 3, 6, 10, 15, 21, 28...Solution ApproachA simple solution to the problem is by finding the general term of the series. On observing the series we can see that the ith number of the series is the sum of (i-1)th term and i.This type of number is called triangular number.To solve the problem, we will loop till n, and for each ... Read More

Find N-th Term of Series 1, 4, 27, 16, 125, 36, 343 in C++

sudhir sharma
Updated on 13-Mar-2021 12:20:32

570 Views

In this problem, we are given an integer N. The task is to find the n-th term in series 1, 4, 27, 16, 125, 36, 343....Let’s take an example to understand the problem, InputN = 7Output343ExplanationThe series is 1, 4, 27, 16, 125, 36, 343…Solution ApproachA simple solution to the problem is by finding the general term of the series. This series comprises two different series one at odd terms and one at even terms. If the current element index is even, the element is square of its index. And if the current element index is odd, the element is ... Read More

Create a Page with Sidebar and Main Content Area using HTML and CSS

AmitDiwan
Updated on 13-Mar-2021 12:20:21

2K+ Views

A webpage with fluid sidebar and main content area is created by setting the size of html and body to 100%.The following example illustrates this.Example Live Demo html,body {    height: 100%;    color: white;    font-size: 2em;    line-height: 200px; } #parent {    display: table;    width: 100%;    height: 100%; } #side {    display: table-cell;    background-color: turquoise;    width: 20%;    vertical-align: top;    box-shadow: inset 0 0 10px black; } #main {    display: table-cell;    width: 80%;    background: url("https://images.unsplash.com/photo-1611944444060- b50a1d80cfe6?crop=entropy&cs=tinysrgb&fit=crop&fm=jpg&h=800&ixlib=rb1.2.1&q=80&w=600"); } Side Main OutputThis will produce the following result −

Full Height Page with Fixed Sidebar in CSS

AmitDiwan
Updated on 13-Mar-2021 12:19:13

6K+ Views

A full-height page with a fixed sidebar and scrollable content area can be created by setting the height to 100% and applying proper positioning of elements.The following example illustrates the above.Example Live Demo .main {    margin-left: 140px;    font-size: 200%;    padding: 0 3%; } section {    height: 400px;    background-color: tomato; } .sidebar {    height: 100%;    width: 140px;    top: 0;    left: 0;    position: fixed;    background-color: darkslategrey;    padding-top: 20px; } .sidebar a {    display: block;    padding: 2% 4%;    text-decoration: none;    color: lightblue;    font-size: 1.4em; ... Read More

Find N-th Term in the Series 9, 33, 73, 129 Using C++

sudhir sharma
Updated on 13-Mar-2021 12:19:06

415 Views

In this problem, we are given an integer N. The task is to find n-th term in series 9, 33, 73, 129....Let’s take an example to understand the problem, InputN = 4Output129ExplanationThe series upto nth term is 9, 33, 73, 129...Solution ApproachThe solution to the problem lies in finding the nth term of the series. We will find it mathematically and then apply the general term formula to our program.First let’s subtract the series by shifting it by one.Sum = 9 + 33 + 73 + … + t(n-1) + t(n) - Sum = 9 + 33 + 73 + ... Read More

C++ Program to Find N-th Term in the Series 7, 15, 32

sudhir sharma
Updated on 13-Mar-2021 12:17:07

190 Views

In this problem, we are given an integer N. The task is to find n-th term in series 7, 15, 32....Let’s take an example to understand the problem, InputN = 6Output281ExplanationThe series upto nth term is 7, 15, 32, 67, 138, 281Solution ApproachThe solution to the problem lies in decoding the series. You can see the series is a mix of series.The subtracting the values, T(2) - T(1) = 15 - 7 = 8 T(3) - T(2) = 32 - 15 = 17 So, T(2) = 2*T(1) + 1 T(3) = 2*T(2) + 2 T(n) = 2*T(n-1) + ... Read More

Find N-th Term in Series 1, 2, 2, 3, 3, 3, 4 in C++

sudhir sharma
Updated on 13-Mar-2021 12:14:13

406 Views

In this problem, we are given an integer N. The task is to find n-th term in series 1 2 2 3 3 3 4….Let’s take an example to understand the problem, InputN = 6Output3ExplanationThe series upto nth term is 1, 2, 2, 3, 3, 3, ...Solution ApproachA simple approach to solve the problem is by using a nested loop. The outer for loop is from 1 to n. And the inner loop is from 1 to i (iterator of outer loop). For each iteration in the inner loop, count the number of elements of the series and return the ... Read More

Advertisements