In mathematics, Euclid's algorithm is a method for computing the greatest common divisor (GCD) of two numbers, the largest number that divides both of them without leaving a remainder. The Euclidean algorithm is based on the principle that the greatest common divisor of two numbers does not change if the larger number is replaced by its difference with the smaller number. For example, 21 is the GCD of 252 and 105 (as 252 = 21 × 12 and 105 = 21 × 5), and the same number 21 is also the GCD of 105 and 252 − 105 ... Read More
We need to write a JavaScript function that creates an acronym from a string by taking the first letter of each word that starts with an uppercase letter. The function should build and return the acronym based on the string phrase provided as input. While constructing the acronym, the function should only consider words that start with an uppercase letter. Problem Statement Given a string like "Polar Satellite Launch Vehicle", we want to extract the first letter of each capitalized word to form "PSLV". Input: 'Polar Satellite Launch Vehicle' Output: 'PSLV' Solution ... Read More
Palindrome Sequence A palindromic subsequence is a sequence that reads the same from front and back. For instance, 'aba', 'madam', 'did' are all valid palindromic sequences. A subsequence can be contiguous or non-contiguous - we can skip characters but maintain their relative order. We need to write a JavaScript function that counts all possible palindromic subsequences within a string. The input string contains only characters 'a', 'b', 'c', and 'd'. Problem Example For the string 'bccb', the palindromic subsequences are: Input: "bccb" Palindromic subsequences: 'b', 'c', 'c', 'b', 'cc', 'bb', 'bcb', 'bccb' Total count: ... Read More
Problem We need to write a JavaScript function that takes a range array of two numbers and returns the count of prime numbers whose squared sum of digits eventually reduces to 1 through repeated calculation. For example, 23 is a prime number and: 2² + 3² = 4 + 9 = 13 1² + 3² = 1 + 9 = 10 1² + 0² = 1 + 0 = 1 Since the process eventually reaches 1, the number 23 qualifies as a "happy prime". Understanding the Solution The solution involves three key functions: ... Read More
The crypto.createSign() method creates and returns a Sign object that uses the specified algorithm for generating digital signatures. You can use crypto.getHashes() to get the names of all available digest algorithms. Sign instances can also be created using signature algorithms like 'RSA-SHA256' in some cases. Syntax crypto.createSign(algorithm, [options]) Parameters The parameters are described as follows: algorithm – The algorithm name to be used while creating the sign object/instance (e.g., 'SHA256', 'RSA-SHA256'). ... Read More
React Native provides the Picker component (now deprecated) and modern alternatives for creating dropdown selections. This guide covers both approaches. Basic Picker Syntax The traditional Picker component follows this structure: Import the Picker component from React Native: import { Picker } from 'react-native' Picker Properties Property Description enabled Boolean value. If false, picker is disabled and user cannot select items. itemStyle Styling to be applied to picker items. ... Read More
A student grade calculator is a web application that takes subject grades as input and calculates the overall percentage and letter grade. This interactive tool provides instant feedback on academic performance using HTML for structure, CSS for styling, and JavaScript for calculations. The percentage calculation formula is: Percentage = (Total Marks Scored / Total Maximum Marks) × 100 How It Works The calculator follows these steps: User enters marks for different subjects through HTML input fields JavaScript function retrieves and validates the input values ... Read More
In this article, we are going to learn about parallax effects and how to create them using HTML, CSS, and JavaScript. We will be using the mouse-move event to show the parallax effect. During the parallax effect, two different images move in parallel to each other. Both the images will be working parallel and making the same transitions. The only difference will be they move in the opposite directions. Parallax effects are used for making websites better in terms of User Experience and enhancing the interactivity level of the website. We can move the foreground and the background images ... Read More
We are required to write a function that takes in two arguments, first is a string and second is a number. The length of string is always less than or equal to the number. We have to insert some random lowercase alphabets at the end of the string so that its length becomes exactly equal to the number and we have to return the new string. Example Let's write the code for this function — const padString = (str, len) => { if(str.length < len){ ... Read More
In JavaScript, validating user input to accept only numbers within a specific range is a common requirement. This is particularly useful for form validation, color values (RGB components), or any scenario where you need to ensure numeric input falls within defined bounds. In this article, we will explore different methods to accept only numbers between 0 and 255 range using JavaScript. This range is commonly used for RGB color values, where each color component must be between 0 and 255. Using if else Condition The if/else statement executes a block of code when a condition is true, ... Read More
Data Structure
Networking
RDBMS
Operating System
Java
iOS
HTML
CSS
Android
Python
C Programming
C++
C#
MongoDB
MySQL
Javascript
PHP
Economics & Finance