## Prolog Program to Reverse a List

In this post, we will see how to reverse a list in prolog. Program Output Explaination The first parameter in the reverse/3 predicate is the list. The second parameter is an empty list. The third parameter is the reverse list. The reverse/3 recursively pushes the elements from the beginning of the first list to the …

## Prove that the 1+3+5+…+(2n-1)=n^2 for every positive integer

Given 1 + 3 + 5 + 7 + ⋯ + (2n-1) = n2 ∀ n ∈ N Proof We will prove the statement by mathematical induction. STEP 1 In this step, we check if the statement is true for n = 1. LHS = 1 + 3 + 5 + 7 + ⋯ + …

## Prove that the sum of the first n odd numbers is a perfect square

Given 1 + 3 + 5 + 7 + ⋯ + (2n-1) = m2 ∀ n, m ∈ N Proof Let, S = 1 + 3 + 5 + .. + (2n-5) + (2n-3) + (2n-1) S is the summation of first n odd numbers. 2*S = ( 1 + 3 + 5 + .. …

What is Adjacency Matrix Graph Representation? Adjacency Matrix is a graph data structure. It is a technique to store graphs. The adjacency matrix is a 2D boolean array of size V2 where V is the number of vertices in the graph. The adjacency matrix contains V rows and V columns. The i-th row and j-th …

## Prove that 4^n-3n-1 is divisible by 9

To Prove 4n – 3n – 1 is divisible by 9 ∀ n ∈ N Proof We will prove the given statement using mathematical induction. Step 1 First, we will check if the given statement is true for n = 1. 4n – 3n – 1 = 41 – 3(1) – 1 = 4 – …

## Prove that 3^n-1 is a multiple of 2

To Prove 3n – 1 is a multiple of 2 ∀ n ∈ N Proof We can prove the given statement using many ways. We will discuss 2 of them. Direct Proof We know the product of two odd numbers is always an odd number. This implies that the term 3n is always odd ∀ n …

## Prove that n^3+5n is divisible by 6

To Prove n3 + 5n is divisible by 6 ∀ n ∈ N Proof We will prove the given statement using the principle of mathematical induction Step 1 We need to check if the statement is true for n = 1. n3 + 5n = 13 + 5(1) = 1 + 5 = 6 Therefore, the statement is …

## Prove that n^2-n is divisible by 2

To Prove n2 – n is divisible by 2 ∀ n ∈ Z Proof n2 – n = n * (n – 1) For the value of n, we have 2 cases n is evenIf n is even, then n * (n – 1) is even since multiplying even number and odd number gives even number. Therefore, …

## Prove that n^2+n is even

To Prove n2 + n is even ∀ n ∈ Z Proof n2 + n = n * (n + 1) For the value of n, we have 2 cases n is evenIf n is even, then n * (n + 1) will also be even since multiplying even number with any integer gives even …

## Program to check whether a given graph is Bipartite

In this article, we will explain how we can check if a given graph is bipartite or not in detail. Basic Terminologies Bipartite Graph: A simple graph G(V, E) is called Bipartite Graph if it’s vertices can be partitioned into two disjoint sets – V1 and V2, such that no edge connects vertices belonging to …