What do understand by the question embedded in the title i.e Maximize a value for a semicircle of a given radius? The title `Maximize a value for a semicircle of a given radius` sounds unclear. Isn’t it? Let’s discuss what it means in the article below: According to the title, If we have a semicircle with radius R, we need to find the maximum value of the expression F = PS^2 + PQ, where P is a point on the circumference of the semicircle, and PQ and PS are the two segments connecting P to the two endpoints of ... Read More
Graphs in Python can be plotted by using the Matplotlib library. Matplotlib library is mainly used for graph plotting.You need to install matplotlib before using it to plot graphs. Matplotlib is used to draw a simple line, bargraphs, histograms and piecharts. Inbuilt functions are available to draw all types of graphs in the matplotlib library.Plot a line in a graphWe will plot a simple line in a graph using matplotlib. The following steps are involved in plotting a line.Import matplotlibSpecify the x-coordinates and y-coordinates of the linePlot the specified points using specific function using .plot() functionName the x-axis and y-axis ... Read More
The concept of an amicable pair of numbers or a friendly pair of numbers seems interesting right? So what exactly are amicable pairs of numbers? Two numbers are said to be an amicable pair of numbers only if the sum of the first number's proper divisors equals the sum of the second number's proper divisors. Also just in case you had forgotten, The Pythagoreans were always known for associating numbers with characteristics like justice and friendship. Problem Statement Implement a program to check whether the given pair of numbers is an amicable pair or not. ... Read More
Prime numbers are those numbers that are greater than one and they simply have two factors: the number itself and factor 1. This indicates that no number apart from 1 as well as the number itself could be used to divide these numbers without leaving a residue. For instance, the first ten prime numbers are 2, 3, 5, 7, 11, 13, 17, 19, 23, and 29. If we take the number 2, the factors are 2 and 1. That is the number itself and the factor 1. Similarly, if we take 11, the factors are 11 and 1. That is ... Read More
The aim of this article is to implement a program to print the Stern-Brocot sequence. What is the Stern-Brocot sequence? Stern-Brocot sequence, which is also known as Stern’s diatomic series, is a sequence of numbers generated as given below. 1, 1, 2, 1, 3, 2, 3, 1, 4, 3, 5, 2, 5, 3, ... Although one may find that the Stern-Brocot sequence quite resembles the Fibonacci sequence 0, 1, 1, 2, 3, 5, 8, 13, 21, 34, ... The Stern-Brocot sequence differs from the Fibonacci sequence in the method the Fibonacci sequence is produced. In ... Read More
In this article our aim is to determine the most steps one can take in a row, provided the heights of the adjacent buildings, to gain altitude as he moves in from roof of one to the roof of the adjacent building. That is building heights for each one after another are provided. You can proceed from one building's roof to the next one down the block. You must determine how many consecutive steps you could indeed take in a row while still gaining altitude with each one. Problem Statement Maximize consecutive steps one can put forward on ... Read More
In this article, our aim is to determine the Simple Moving Average of the given values in the array. Let us take a quick glance at what Simple Moving Average means. The average derived from the data over a certain amount of time (t) is known as the simple moving average. In a typical mean, the Simple Moving Average value changes as a result of changing data, but in this kind of mean, it also varies over time. After obtaining the mean for a given period t, some earlier data is then eliminated. We receive new mean once more ... Read More
The aim of this article here is to make the elements distinct in a sorted array by minimum increments. First, an array of integers that has been sorted is provided. By increasing the values and keeping the array sum as low as possible, we must make array elements discrete from one another. As the output, we must display the smallest amount as the sum that is achievable. Problem Statement Make elements distinct in a sorted array by minimum increments. Approach Given an integer array of sorted numbers. We first check whether the elements in the given ... Read More
In this article, our primary aim is to come up with a solution to implement a random-0-6-Generator using the given random-0-1-Generator. As we know, A random-0-1-Generator() function returns either 0 or 1 as the output. Similarly, a random-0-6-Generator, as the name suggests, gives any random numbers between 0 and 6 (including 0 and 6). Also, a main point to keep in mind is that the random-0-6-Generator should generate random numbers ranging between 1 to 6, with equal probability. That is the probability of obtaining any number should always be the same. Example For instance, the random ... Read More
A Fibonacci series is found in every row of the Fibonacci triangle. What is a fibonacci series? In the Fibonacci series, each digit equals the sum of the two integers before it. This series' first two digits are 1 and 1. The next elements in the series are computed as the sum of two numbers previous to it. The Fibonacci series is produced as 1+1=2, 2+3=5, 3+5=8, 8+13=21, 13+21=34 and so on. Likewise, the Fibonacci triangle series goes like 1, 1, 2, 3, 5, 8, 13, 21, 34, 55… Problem Statement Implement a program to ... Read More