Article Categories
- All Categories
-
Data Structure
-
Networking
-
RDBMS
-
Operating System
-
Java
-
MS Excel
-
iOS
-
HTML
-
CSS
-
Android
-
Python
-
C Programming
-
C++
-
C#
-
MongoDB
-
MySQL
-
Javascript
-
PHP
Articles by Ashin Vincent
Page 2 of 3
Giuga Number in Java
In this article, we will learn about Giuga Numbers and how to write a code to check if a number is a Giuga Number or not in Java. A Giuga number is a composite number N such that for each prime factor p of N, (N/p)-1 is divisible by p. The first Giuga numbers are 30, 858, 1722, 66198, 2214408306, 24423128562, and 432749205173838. Example Lets take N=30. 30 is a composite number, and its prime factors are 2, 3, and 5. ● For p=2: (N/p)-1 to be divisible by p. N is 30, and p here is 2. (30/2)-1=14, ...
Read MoreDuodecimal in java
The duodecimal number system is also known as the base-12 number system. The decimal system (base-12) uses digits 0-9, while the duodecimal system uses digits 0-9 along with two additional symbols, A and B. In duodecimal, 10 represents 12 , which means 12 in the decimal number system is 10 in the duodecimal system. We often encounter duodecimal in daily life; for example, we have 12 months in a year, 12 zodiac signs, 12 inches in a foot, 12 musical notes in an octave, and we call a group of 12 items a dozen. Representation of duodecimal numbers The duodecimal ...
Read MoreDifference Between JDK and BlueJ
JDK (Java Development Kit) is a software development kit that contains all the necessary tools and components that are essential to develop a Java application. Whereas BlueJ is an IDE that will make the process of developing a Java application a lot easier. BlueJ requires JDK installed on the system to work with Java applications. Java Development Kit (JDK) The Java Development Kit (JDK) contains all the essential libraries, tools, and all other important things to work with Java. You can’t do programming in Java without JDK. The modern IDEs, like "IntelliJ IDEA" will already be equipped with Java essential ...
Read MoreChecking if Two Words Are Present in a String in Java
In this article, we will learn how to check if two given words are present in a string. This is useful when you need to check for multiple words in the text for different purposes, like searching, filtering, or text analysis. We will explore different approaches on how to implement it in Java, starting from the simple method to more advanced techniques. Example Scenario Consider this string: "Java provides powerful libraries for developers." We want to check if both "java" and "libraries" appear in the text. In this case, the output will be true. 1.Using contains() The contains() method checks ...
Read MoreJava Program to Find Two Elements Whose Sum is Closest to Zero
In this article we will learn how to find the two elements in an array whose sum is closest to zero. The array can contain both positive and negative values as well. Let's understand with the help of an example. Example Let's take an array with the following elements − arr = {3, -56, -76, -32, 45, 77, -14, 13, 92, 37} Here, two elements whose sum is closest to zero are 77 and -76, and their sum is 1. Note: In this example we have 77 and -76, which will give the sum as 1, and also ...
Read MoreLength of the longest consecutive zeroes in the binary representation of a number in java
You are given a number (N); you need to find the length of the longest consecutive zeroes in the binary representation of the number using different approaches. Example Input N = 529 The binary form of 529 is 1000010001. Output The longest chain of zeroes in the binary form is 0000 with a length of 4. Hence, the answer is 4. Approach 1: Using Division and Modulus In this approach we use division and modulus operations to convert decimal to binary and then count the maximum zeroes in the binary number. Steps for implementation The following steps explain ...
Read MoreLead Number in java
A lead number is a number whose sum of even digits is equal to the sum of odd digits. In this article, we will learn about lead numbers and programs to check if a number is a lead number or not. Lead number example Let’s take the number 615341. The sum of even digits is 6 + 4 = 10. The sum of odd digits is 1 + 5 + 3 + 1 = 10. Here, the sum of even digits = the sum of odd digits, so 615341 is a lead number Arithmetic Approach This approach extracts digits ...
Read MoreJava Program to Implement Associative Array
What is an associative array? An associative array stores data in key-value pairs where we can retrieve values using unique keys. There is a significant difference between standard arrays and associative arrays. Normal arrays use numbers for indexing (like arr[0], arr[1], arr[2]). Whereas in an associative array, we use meaningful names such as "name" or "city” to identify each value. Example Let's consider a list of student grades where names act as keys − Key (Student Name): Value (Marks) Raju: 85 Krishna: 90 Yash: 78 This lets us find the grades of students by using their names instead of ...
Read MoreJava Program to Print Odd Elements at Odd Index
In this article, we will learn how to find and print the odd numbers that are present at odd index positions in an array. First we will understand the problem with the help of an example, and then we will learn three approaches to implement it in Java. Example Consider the array = [2, 1, 4, 4, 5, 7]. The odd numbers at odd indices are 1 and 7. Explanation The indexing of an array starts from 0. Here the element 1, which is an odd number, is present at index 1, which is an odd index. In the same ...
Read MoreJava Program to Generate Random Hexadecimal Value
In this article, we will learn how to generate random hexadecimal number values in Java. Random hexadecimal values are used in many applications, like unique identifiers, cryptographic keys, session tokens, or colour codes. We will discuss three different ways to generate random hexadecimal values in Java − Using Random – A simple, fast method to make random hexadecimal values. Using SecureRandom – Best for secure random hexadecimal numbers. Using BigInteger – Helps produce large random hexadecimal numbers. 1. Using Random In this approach, we use the Random class to produce random numbers from 0 to 15. After ...
Read More