C++ Program to Implement Modular Exponentiation Algorithm

Nishtha Thakur
Updated on 30-Jul-2019 22:30:25

2K+ Views

This is a C++ program to implement Modular Exponentiation Algorithm.AlgorithmBegin    function modular():    // Arguments: base, exp, mod.    // Body of the function:       initialize res = 1       while (exp > 0)          if (exp mod 2 == 1)          res= (res * base) % mod          exp = exp left shift 1          base = (base * base) % mod       return res. EndExample#include using namespace std; long long modular(long long base, long long exp, int mod) {    long long res = 1;    while (exp > 0) {       if (exp % 2 == 1)          res= (res * base) % mod;       exp = exp >> 1;       base = (base * base) % mod;    }    return res; } int main() {    long long b, e;    int mod;    coutb;    coute;    coutmod;    cout

Know Whether Your Training is Effective or Not

Anuradha Nanda
Updated on 30-Jul-2019 22:30:25

172 Views

The first day of employment for any employee: be a fresher, experienced person, or managerial, will always start off with a training session. The day-long training completes with numerous amount of information, but does so much effort made by the Organization is worth the money invested in the training sessions. We all agree that training is the key to a well-motivated, knowledgeable, and efficient staff.Here we are going to discuss the top reasons on why the training sessions do not help your employees, and why this whole expenditure on training is not fruitful. We will check out the conditions because of ... Read More

Why People Buy Kindle Despite Its Single Functionality

Suman Nanda
Updated on 30-Jul-2019 22:30:25

133 Views

Kindle is great to reduce eye tension. Kindle is absolutely easy on your sight and is very comfortable to read on. As well, the display on the latest Kindle is built to prevent glare, even in sunlight. In addition to that:Perfect Travel-Around PartnerThe Kindle is so small, light and portable that it is straightforward to carry around anywhere you go and also you don't have to worry about the edges of your publication folding anymore. It also helps that your total library suits this tiny device, so you're indulged for choice while on vacation.Read At NighttimeIf you want to learn ... Read More

Run Continuous Thread in Android

Nitya Raut
Updated on 30-Jul-2019 22:30:25

605 Views

Before getting into an example, we should know what thread in android is. Threads are generic processing tasks that can do most things, but one thing they cannot do is update the UI.This example demonstrates about How to run continues thread in android.Step 1 − Create a new project in Android Studio, go to File ⇒ New Project and fill all required details to create a new project.Step 2 − Add the following code to res/layout/activity_main.xml. In the above code, we have taken textview. When the user clicks on textview, it will start continues thread ... Read More

Create Septet Tuple in Java Using with Method

Samual Sam
Updated on 30-Jul-2019 22:30:25

120 Views

The with() method is used to create Septet Tuple in Java.Let us first see what we need to work with JavaTuples. To work with Septet class in JavaTuples, you need to import the following package −import org.javatuples.Septet;Note − Steps to download and run JavaTuples program If you are using Eclipse IDE to run Septet Class in JavaTuples, then Right Click Project → Properties → Java Build Path → Add External Jars and upload the downloaded JavaTuples jar file.The following is an example −Exampleimport org.javatuples.Septet; public class Demo {    public static void main(String[] args) {       Septet < ... Read More

Type 2 Driver of JDBC: Advantages and Disadvantages

Daniol Thomas
Updated on 30-Jul-2019 22:30:25

902 Views

This driver is known as a native API driver. This driver receives the calls from Java application and converts them in to vender specific native API calls. Here, we need to install The vendor-specific driver on the client machines.If we change the Database, we have to change the native API, as it is specific to a database and they are mostly obsolete now, but you may realize some speed increase with a Type 2 driver because it eliminates ODBC's overhead.Advantages of type2 driverFollowing are the advantages of the type2 driver.This type of driver fastest among all the 4 types of ... Read More

Read Cookies with JSP

karthikeya Boyini
Updated on 30-Jul-2019 22:30:25

1K+ Views

To read cookies, you need to create an array of javax.servlet.http.Cookie objects by calling the getCookies( ) method of HttpServletRequest. Then cycle through the array, and use getName() and getValue() methods to access each cookie and associated value.Let us now read cookies that were set in the previous example −Example Live Demo           Reading Cookies                        Reading Cookies                 Let us now put the above code in main.jsp file and try to access it. If you set ... Read More

Use replaceAll in Android TextView

Smita Kapse
Updated on 30-Jul-2019 22:30:25

559 Views

This example demonstrate about How to use replaceAll () in Android textview.Step 1 − Create a new project in Android Studio, go to File ⇒ New Project and fill all required details to create a new project.Step 2 − Add the following code to res/layout/activity_main.xml.             In the above code, we have taken name as Edit text, when user click on button it will take data and replace space with emptystring.Step 3 − Add the following code to src/MainActivity.javapackage com.example.myapplication; import android.os.Bundle; import android.support.v7.app.AppCompatActivity; import android.view.View; import android.widget.Button; import android.widget.EditText; import android.widget.TextView; ... Read More

IntStream anyMatch Method in Java

George John
Updated on 30-Jul-2019 22:30:25

645 Views

The anyMatch() method in the IntStream class in Java returns whether any elements of this stream match the provided predicate.The syntax is as followsboolean anyMatch(IntPredicate predicate)To work with the IntStream class in Java, import the following packageimport java.util.stream.IntStream;Here, the predicate parameter is a stateless predicate to apply to elements of this stream.Create an IntStream and add some elementsIntStream intStream = IntStream.of(20, 40, 60, 80, 100);Now, use the anyMatch() method to set for a condition. If any of the element match with the condition, TRUE is returnedboolean res = intStream.anyMatch(a -> a < 50); The following is an example to implement ... Read More

DoubleStream generate Method in Java

George John
Updated on 30-Jul-2019 22:30:25

197 Views

The generate() method of the DoubleStream class returns an infinite sequential unordered stream where each element is generated by the provided DoubleSupplier.The syntax is as followsstatic DoubleStream generate(DoubleSupplier s)Here, the parameter s is the DoubleSupplier for generated elements. The DoubleSupplier is a supplier of double-valued results. To use the DoubleStream class in Java, import the following packageimport java.util.stream.DoubleStream;The following is an example to implement DoubleStream generate() method in JavaExample Live Demoimport java.util.*; import java.util.stream.DoubleStream; public class Demo {    public static void main(String[] args) {       DoubleStream doubleStream = DoubleStream.generate(()       -> { return (double)(Math.random() * 100); ... Read More

Advertisements