In this problem, we are given a number N. Our task is to create a program to find N-th term of series 0, 11, 28, 51, 79, 115, 156, 203, … In C++.Problem Description − To find the Nth terms of the series −0, 11, 28, 51, 79, 115, 156, 203, … N-th term.Let’s take an example to understand the problem,Input − N = 5Output − 79Solution Approach:The general formula for nth term of the series is −Tn = 3*(N*N) + 2*N - 5Program to illustrate the working of our solution,#include using namespace std; int findNTerm(int N) { int nthTerm = ( (3*N*N) + 2*N - 5); return nthTerm; } int main() { int N = 9; cout
In this problem, we are given a number N. Our task is to create a program to find N-th term of series 2, 12, 28, 50, 77, 112, 152, 198, …in C++.Problem Description − To find the N-th term of the series.2, 12, 28, 50, 77, 112, 152, 198, ...N termsWe will find a general for the series.Let’s take an example to understand the problem, Input − N = 6Output − 112Solution Approach:Here, the series is increasing in parabolic form, so the general term will be a quadratic equation.So, the general formula for the series isTN = 3*(N*N) + N ... Read More
In this problem, we are given a number N. Our task is to create a program to find N-th term of series 1 4 15 24 45 60 92... in C++.Problem description − To find the nth term of the series −1, 4, 15, 24, 45, 60, 92, 112 … N termsWe will find the general formula for the series.Let’s take an example to understand the problem, Input − N = 6Output − 60Solution Approach, The general term of the series is based on whether the value of N is even or odd. This type of series is a bit ... Read More
In this problem, we are given a number N. Our task is to create a program to find N-th term of series 2, 4, 3, 4, 15… in C++.Problem Description − To find the sum of the given series, 2, 4, 3, 4, 15, 0, 14, 16 .... N termsWe will find the formula for the general term of the series.Let’s take an example to understand the problem, Input − N = 9Output − 9Solution Approach:The increase of the values in the series is linear i.e. no square values are in the series. Also, it’s value depends on other factors ... Read More
If you are working on a project that requires frequent copying of files and folders either from container to your local machine or from the local machine to the container, docker provides an easy and simple way to do that. If you have already built a docker image which is of large size and contains a large number of files and in the midst of the project you want to copy files to and from the container, it’s highly inefficient to put the files in the docker build context and build images repeatedly. Instead, docker allows easy copying of files ... Read More
In some projects, there might be scenarios where you have created multiple containers for different parts of the project and some of those containers share common files as well. Now, you want to create a shared directory between all the containers such that from all the containers you can access that directory or volume and perform changes in the files in that directory from any container.You can do so, be creating a volume and mounting it to all the containers. By doing so, all the containers will have shared access to the particular volume and you will be able to ... Read More
Docker allows you to build, manage and deploy applications inside containers. It provides a packed environment and allows developers to make portable applications by containerizing them. You can easily build a flask application, manage it and make it portable all using a single technology, docker. You can use similar techniques to build and deploy other python frameworks as well.In this article, we will be discussing how to build a simple application using flask and convert that into a docker image by containerizing it. You can follow the steps mentioned below to do the same.StepsCreate a new project folder. Let’s name ... Read More
After you have installed docker on your linux machine, the next step is to create an image and run a container. You need to create a base image of an OS distribution and after that you can add and modify the base image by installing packages and dependencies and committing the changes to it.In this article, we will show you how to create an ubuntu base image and on top of that create intermediate image layers by adding packages in it and keep committing the changes. We will update the ubuntu base image, install 3 packages - vim editor, firefox ... Read More
When you are working on a large project on docker, you need to go through certain phases of the development cycle. Maintaining a different dockerfile for each cycle such as build, release, testing etc. eats up a lot of resources and is highly inefficient when it comes to productivity.In the later versions of docker, it allows us to use what is called multi-stage Dockerfile with the help of two particular commands - FROM and AS.We can use multiple FROM commands combined with AS commands in our Dockerfile where the last FROM command will actually build the image. All the FROM ... Read More
The commands RUN, CMD and Entrypoint usually cause a lot of confusion among docker developers. Understanding all the three commands conceptually will help to have a clearer understanding of the same.When we try to build an image using dockerfile, the instructions are executed step by step. The first instruction is usually pulling a base image such as an OS distribution like ubuntu, centos etc. After that, we modify the base image either by including more images using FROM and AS commands or by modifying the images. Every such instruction creates a new intermediate image build and for each of them, ... Read More