Do you need to look through marvelous summation examples? You have such an ability due to Assignment.EssayShark. On our website, you’ll find many examples in diverse technical disciplines. There are samples that present solutions for various tasks in physics, chemistry, programming, math, and other disciplines.

As we have been working with students for a long time, we know which problems they are likely to have while studying. Therefore, we try to select topics for our samples that are difficult for students. However, we don’t have the ability to provide you with samples on each topic in each discipline. So, if you need to use a specific sample that is completed according to your requirements, you will need to make an order.

No matter whether you make an order and pay for a unique quicksort sample or use the free summation examples, you don’t have to worry about the quality of the examples. We do our best to find experts that are extremely knowledgeable in specific spheres. All of them are accredited with high-level academic degrees. Also, we try to find people that have vast practical experience in certain fields.

The example that is presented below also was completed by an expert with vast experience.

Our experts provide you with more than just the correct solutions to specific tasks. Our experts explain how they found the particular solution. If this example doesn’t help you to solve your task, contact us. We will help you to complete your assignment even if your deadline is near at hand. However, you should first take a look at our example, so move straight to it!

## Multiplication, Subtraction, Division of Integers Using Summation Operator

In this task, we can only use the summation operator. In such tasks, it is useful to recall the essence of mathematical operations and their implementation by adding (or using other operations).

## Subtraction

How do you implement the subtraction using summation? It’s very simple. Operation x – y is the same thing as x + (-1) * y. Since we can not use the multiplication operator, we have to create a negation function.

public static int negation(int x) { int neg = 0; int y = x < 0 ? 1 : -1; while (x != 0) { neg += y; x += y; } return neg; } public static int subtract(int x, int y) { return x + negate(y); }

A negative value of k is obtained by summing the number -1, k times.

## Multiplication

The relationship between summation and multiplication is also quite obvious. To multiply x and y, we need to add x value to itself, y times.

public static int mult(int x, int y) { if (x < y) { return mult(y, x); } int sum = 0; for (int i = mod(y); i > 0; i--) { sum += x; } if (y < 0) { sum = negation(sum); } return sum; } public static int mod(int x) { if (x < 0) { return negation(x); } else { return x; } }

We need to pay special attention to the negative numbers. If x – y is a negative number, it is necessary to take into account the sign of the sum of:

multipl (x, y) <- abs (y) * x * (-1 if y <0).

In addition, to solve this problem, we created a simple function mod.

## Division

The most difficult mathematical operation is division. It is a good idea to use the divide multiplication, subtraction and negation methods for the implementation of the division.

We need to find k, if k = x / y. Let us restate the problem: find k when x = yk. Now we change the terms so that the problem could be solved with the help of the already known operation – multiplication.

Note that k can be calculated as the result of the summation of b, until a is obtained. The number of copies of y, required to obtain x, is the value of k.

Of course, this decision cannot be called a full-fledged division, but it works. But using such implementation makes finding the remainder of the division impossible.

The following code implements this algorithm:

public int division(int x, int y) throws java.lang.ArithmeticException { if ( y == 0) { throw new java.lang.ArithmeticException("ERROR"); } int moda = mod(x); int modb = mod(y); int result = 0; int k = 0; while (result + modb <= moda) { result += modb; k++; } if ((x < 0 && y < 0) || (x > 0 && y > 0)) { return k; } else { return negation(k); } }

Thanks for your attention!