Skip to main content

Posts

CPCoders

This website is brought to you by CPCoders.We are working on Competitive Coding Algortihm Libraries for JavaScript. We are currently developing cpmath and cpcodes libraries.
Recent posts

Flood Fill

Given a 2D screen, location of a pixel in the screen and a color, replace color of the given pixel and all adjacent same colored pixels with the given color.

Aho Corasick

Aho–Corasick algorithm is a string-searching algorithm invented by Alfred V. Aho and Margaret J. Corasick. It is a kind of dictionary-matching algorithm that locates elements of a finite set of strings within an input text. It matches all strings simultaneously.

Euler’s Four Square Identity

According to Euler’s four square identity, the product of any two numbers a and b can be expressed as a sum of four squares if a and b both can individually be expressed as sum of four squares.

Jagged Number

A k-rough or k-jagged number is a number whose smallest prime factor is greater than or equal to the number ‘k’. Given numbers ‘n’ and ‘k’ as input, we are required to find whether ‘n; is a k-rough number or not.

Frugal Number

A frugal number is a number whose number of digits is strictly greater than the number of digits in its prime factorization (including exponents). If the exponent is 1 for a certain prime, involved in the prime factorization, then that exponent does not contribute to the number of digits in the prime factorization.

Blum Integer

Blum Integer is the number which only haves 2 factors suppose p and q (i.e. n = p * q), both are Semi-prime and also they(p and q) are of the form 4t + 3, where t is some integer. First few Blum Integers are 21, 33, 57, 69, 77, 93, 129, 133, 141, 161, 177, … Note: Because of the condition that both the factors should be semi-primes, even numbers can not be Blum integers neither can be the numbers below 20, So we have to check only for an odd integer greater than 20 that if it is a Blum Integer or not.

Lemoine’s Conjecture

Any odd integer greater than 5 can be expressed as a sum of an odd prime (all primes other than 2 are odd) and an even semiprime. A semiprime number is a product of two prime numbers. This is called Lemoine’s conjecture.

Betrothed numbers

Betrothed numbers are two positive numbers such that the sum of the proper divisors of either number is one more than (or one plus) the value of the other number. Our task is to find these pairs efficiently.

Aliquot Sum

In number theory, the aliquot sum s(n) of a positive integer n is the sum of all proper divisors of n, that is, all divisors of n other than n itself. They are defined by the sums of their aliquot divisors. The aliquot divisors of a number are all of its divisors except the number itself. The aliquot sum is the sum of the aliquot divisors so, for example, the aliquot divisors of 12 are 1, 2, 3, 4, and 6 and it’s aliquot sum is 16.

Fermat's Last Theorem

According to Fermat’s Last Theorem, no three positive integers a, b, c satisfy the equation, a^n + b^n = c^n for any integer value of n greater than 2. For n = 1 and n = 2, the equation have infinitely many solutions.