## Prove that if n is an integer and 3n+2 is even then n is even

Given If 3n + 2 is even then n is even ∀ n ∈ Z Proof By Contradiction We will prove the given statement by contradiction Suppose 3n+2 is even. Assume n is odd. If n is odd, then we can write n as n = 2k + 1, k ∈ Z Substitute n in …

## Prove by induction that 1+3+5+7+⋯+(2n-1)=n^2

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

## C/C++ Program to remove all zeros from a number

Write a program to remove all zeros from a integer number in C/C++. For example, Input 809210003 Output 89213 Steps Take input from the user. Let it be N. Set num = 0. num will store the output. Repeat the following steps while N > 0 Set R = N % 10. This step stores …

## Levenshtein Distance

Introduction Levenshtein distance between two strings is defined as the minimum number of single-digit edit operations ( Insertion, Deletion, Substitution ) required to convert one string to another. Single Digit Operations Insertion : “Sprk” -> “Spark” Deletion : “Hello” -> “Hllo” Replace : “Carry” -> “Larry” For example, Example 1 s1 = “gone” s2 = …

## Prove that 2^n + 1 is divisible by 3 for all positive odd integers n

Given 2n + 1 is divisible by 3 ∀ n ∈ O+ Proof We will prove the given statement by induction. STEP 1 n = 1 2n + 1 = 21 + 1 = 3 3 is divisible by 3. Therefore, the statement is true for n = 1 STEP 2 Let the given statement …

## Prove that n^3+2n is divisible by 3

Given n3 + 2n is divisible by 3 ∀ n ∈ N Proof We will prove the given statement by induction STEP 1 n = 1 n3 + 2n = 13 + 2*1 = 3 3 is divisible by 3. Therefore, the statement is true for n = 1 STEP 2 Let the given statement …

## Prove that n^3-7n+3 is divisible by 3

Given n3 – 7n + 3 is divisible by 3 ∀ n ∈ N Proof We will prove the given statement by induction STEP 1 n = 1 n3 – 7n + 3 = 13 – 7*1 + 3 = -3 -3 is divisible by 3. Therefore, the statement is true for n = 1 …

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

Given n3 – n is divisible by 3 ∀ n ∈ N Proof We will prove the given statement by induction STEP 1 n = 1 n3 – n = 13 – 1 = 0 0 is divisible by 3. Therefore, the statement is true for n = 1 STEP 2 Let the given statement …

## Prove that n^3+2 is not divisible by 8

Given n3+ 2 is not divisible by 8 ∀ n ∈ N Proof For value of n, we have 2 cases CASE 1 : n is odd If n is odd then n3 is also odd. We know ODD + EVEN = ODD. Therefore, n3+2 is odd. 8 cannot divide an odd number. We can …

## Prove by induction n^3+(n+1)^3+(n+2)^3 is divisible by 9

Given n3 + (n + 1)3 + (n + 2)3 is divisible by 9 ∀ n ∈ N Proof We will prove the given statement by induction STEP 1 n = 1 13 + (1 + 1)3 + (1 + 2)3= 13 + 23 + 33 = 1 + 8 + 27 = 36 36 …