Chandu yadav

Chandu yadav

810 Articles Published

Articles by Chandu yadav

Page 15 of 81

Modular multiplicative inverse in java

Chandu yadav
Chandu yadav
Updated on 25-Jun-2020 1K+ Views

The java.math.BigInteger.modInverse(BigInteger m) returns a BigInteger whose value is (this-1 mod m). Using this method you can calculate Modular multiplicative inverse for a given number.ProgramLive Demoimport java.math.*; public class BigIntegerDemo {    public static void main(String[] args) {       // create 3 BigInteger objects       BigInteger bi1, bi2, bi3;             // create a BigInteger exponent       BigInteger exponent = new BigInteger("2");       bi1 = new BigInteger("7");       bi2 = new BigInteger("20");             // perform modPow operation on bi1 using bi2 and exp       bi3 = bi1.modPow(exponent, bi2);       String str = bi1 + "^" +exponent+ " mod " + bi2 + " is " +bi3;             // print bi3 value       System.out.println( str );    } }Output7^2 mod 20 is 9

Read More

Smith Numbers in java

Chandu yadav
Chandu yadav
Updated on 25-Jun-2020 1K+ Views

A composite number whose sum of digits equal to the sum of the digits of its prime factors.Ex: 58 = 2 x 29 (5 + 8 = 12) (2+ 2 + 9 = 12)Programpublic class SmithNumbers {    public static boolean isPrime(int number) {       int loop;       int prime = 1;       for(loop = 2; loop < number; loop++) {          if((number % loop) == 0) {             prime = 0;          }       }       if (prime ...

Read More

Check if a large number is divisible by 11 or not in java

Chandu yadav
Chandu yadav
Updated on 25-Jun-2020 2K+ Views

A number is divisible by 11 if the difference between the sum of its alternative digits is divisible by 11.i.e. if (sum of odd digits) – ( sum of even digits) is 0 or divisible by 11 then the given number is divisible by 11.Programimport java.util.Scanner; public class DivisibleBy11 {    public static void main(String args[]) {       Scanner sc = new Scanner(System.in);       System.out.println("Enter a number :");       String num = sc.nextLine();       int digitSumEve = 0;       int digitSumOdd = 0;            for(int i = 0; i

Read More

GCD and LCM of two numbers in Java

Chandu yadav
Chandu yadav
Updated on 25-Jun-2020 1K+ Views

Following is an example which computes find LCM and GCD of two given numbers.Programimport java.util.Scanner; public class LCM_GCD {    public static void lcm(int a, int b){       int max, step, lcm = 0;       if(a > b){          max = step = a;       } else{          max = step = b;       }       while(a!= 0) {          if(max%a == 0 && max%b == 0) {             lcm = max;             break;          }          max += step;       }       System.out.println("LCM of given numbers is :: "+lcm);    }    public static void gcd(int a,int b){       int i, hcf = 0;          for(i = 1; i

Read More

Perform Animation on border-right-width property

Chandu yadav
Chandu yadav
Updated on 25-Jun-2020 130 Views

To implement animation on border-right-width property with CSS, you can try to run the following codeExampleLive Demo                    div {             width: 500px;             height: 300px;             background: yellow;             border: 15px solid yellow;             background-image: url('https://www.tutorialspoint.com/latest/cuda.png');             animation: myanim 3s infinite;             background-position: bottom left;             background-size: 50px;          }          @keyframes myanim {             30% {                background-color: maroon;                border-right-color: red;                border-right-width: 25px;             }          }                     Performing Animation for border right width              

Read More

Animated background with CSS

Chandu yadav
Chandu yadav
Updated on 25-Jun-2020 694 Views

Use the @keyframes to animate. To implement animation on background with CSS, you can try to run the following codeExampleLive Demo                    div {             width: 400px;             height: 300px;             animation: myanim 3s infinite;          }          @keyframes myanim {             30% {                background: green bottom right/50px 50px;             }          }                        

Read More

MySQL Mass Update with CASE WHEN/ THEN/ ELSE?

Chandu yadav
Chandu yadav
Updated on 25-Jun-2020 10K+ Views

The syntax for mass update with CASE WHEN/ THEN/ ELSE is as follows −UPDATE yourTableName set yourColumnName=case when yourColumnName=Value1 then anyUpdatedValue1 when yourColumnName=Value2 then anyUpdatedValue2 when yourColumnName=Value3 then anyUpdatedValue3 when yourColumnName=Value4 then anyUpdatedValue4 else yourColumnName end;To understand the above syntax, let us first create a table. The query to create a table is as follows −mysql> create table CaseUpdateDemo -> ( -> Id int, -> Name varchar(100) -> ); Query OK, 0 rows affected (0.78 sec)Insert some records in the table using insert command. The query is as follows −mysql> insert into CaseUpdateDemo values(1, 'John'); Query OK, 1 row affected ...

Read More

Fetching rows added in last hour with MySQL?

Chandu yadav
Chandu yadav
Updated on 25-Jun-2020 6K+ Views

You can use date-sub() and now() function from MySQL to fetch the rows added in last hour.SyntaxThe syntax is as follows −select *from yourTableName where yourDateTimeColumnName create table LastHourRecords -> ( -> Id int, -> Name varchar(100), -> Login datetime -> ); Query OK, 0 rows affected (0.67 sec)Insert records in the form of datetime using insert command. The query to insert record is as follows −mysql> insert into LastHourRecords values(1, 'John', ' 2018-12-19 10:00:00'); Query OK, 1 row affected (0.17 sec) mysql> insert into LastHourRecords values(2, 'Carol', '2018-12-19 10:10:00'); Query OK, 1 row affected (0.15 sec) ...

Read More

Get the time difference and convert it to hours in MySQL?

Chandu yadav
Chandu yadav
Updated on 25-Jun-2020 2K+ Views

You can achieve with the help of timestampdiff() method from MySQL. The syntax is as follows −SyntaxSELECT ABS(TIMESTAMPDIFF(HOUR, yourColumnName1, yourColumnName2)) as anyVariableName from yourTableName;To understand the above syntax, let us create a table. The query to create a table is as follows −mysql> create table DifferenceInHours    -> (    -> StartDateTime datetime,    -> EndDateTime datetime    -> ); Query OK, 0 rows affected (0.59 sec)Insert some records in the table using insert command. The query is as follows −mysql> insert into DifferenceInHours values('2018-12-20 10:00:00', '2018-12-19 12:00:00'); Query OK, 1 row affected (0.11 sec) mysql> insert into DifferenceInHours ...

Read More

Set whether the text should be overridden to support multiple languages with CSS

Chandu yadav
Chandu yadav
Updated on 25-Jun-2020 137 Views

Use the unicode-bdi property to set whether the text should be overridden to support multiple languages with CSSExampleLive Demo                    p.demo1 {             direction: rtl;             unicode-bidi: bidi-override;          }          p.demo2 {             direction: rtl;             unicode-bidi: isolate;          }                     The unicode-bidi Property       This is demo text.       This is demo text       This is demo text    

Read More
Showing 141–150 of 810 articles
« Prev 1 13 14 15 16 17 81 Next »
Advertisements