Tag Archives: series

Recaman’s sequence

Given an integer n. Print first n elements of Recaman’s sequence. Examples: Input : n = 6 Output : 0, 1, 3, 6, 2, 7 Input : n = 17 Output : 0, 1, 3, 6, 2, 7, 13, 20, 12, 21, 11, 22, 10, 23, 9, 24, 8 It is basically a function with… Read More »

Superperfect Number

Given an integer n. Check whether the number n is superperfect number or not. A superperfect number is a positive integer which satisfies σ2(n) = σ(σ(n)) = 2n, where σ is divisor summatory function. Input: n = 16 Output: yes Explanation: 16 is a superperfect number as σ(16) = 1 + 2 + 4 +… Read More »

Program to find Cullen Number

A Cullen Number is a number of the form is 2n * n + 1 where n is an integer. The first few Cullen numbers are 1, 3, 9, 25, 65, 161, 385, 897, 2049, 4609 . . . . . . Examples: Input : n = 4 Output :65 Input : n = 0… Read More »

Reversible numbers

A number is said to be a reversible if sum of the number and its reverse had only odd digits. The problem is to find out if a number is reversible or not. Examples: Input: 36 Output: Reversible number as 36 + 63 = 99 has only odd digits. Input: 409 Output: Reversible number as… Read More »

Sum of Perrin Numbers

Given a number positive number n, find value of P0 + P1 + P2 + …. + Pn where pi indicates i’th Perrin number. First few Perrin numbers are 3, 0, 2, 3, 2, 5, 5, 7……. Examples: Input : 4 Output : 8 Explanation : 3 + 0 + 2 + 3 Input :… Read More »

Program for Perrin numbers

The Perrin numbers are the numbers in the following integer sequence. 3, 0, 2, 3, 2, 5, 5, 7, 10, 12, 17, 22, 29, 39 … In mathematical terms, the sequence p(n) of Perrin numbers is defined by the recurrence relation P(n) = P(n-2) + P(n-3) for n > 2, with initial values P(0) =… Read More »

Equidigital Numbers

A number n is called Equidigital if the number of digits in the prime factorization of n (including powers) is same as number of digits in n. For example 16 is an Equidigital number as its prime factorization is 2^4 and its prime factorization has total two digits (2 and 4) which is same as… Read More »

Aliquot Sequence

Given a number n, the task is to print its Aliquot Sequence. Aliquot Sequence of a number starts with itself, remaining terms of the sequence are sum of proper divisors of immediate previous term. For example, Aliquot Sequence for 10 is 10, 8, 7, 1, 0. The sequence may repeat. For example, for 6, we… Read More »

Carol Number

A Carol number is an integer of the form 4n – 2(n+1) – 1. An equivalent formula is (2n-1)2 – 2. An Interesting Property : For n > 2, the binary representation of the n-th Carol number is n-2 consecutive one’s, a single zero in the middle, and n + 1 more consecutive one’s. Example,… Read More »