Wednesday, 1 Dec 2021
Category: Sequence and Series

Given an integer N, the task is to find the subfactorial of the number represented as !N. The subfactorial of a number is defined using below recurrence relation of a number N:!N = (N-1) [ !(N-2) + !(N-1) ]where !1 = 0 and !0 = 1Some of the subfactorials are:n012345678910111213!n10129442651, 85414, 833133, 4961, 334, 96114, […]

Mean of fourth powers of first N natural numbersGiven a positive integer N, the task is to find the average of the fourth powers of the first N natural numbers.Examples:Input: N = 3Output: 32.6667Explanation:Sum of the fourth powers of the first N natural numbers = 14 + 24 + 34 = 1 + 16 + […]

Generate a permutation of first N natural numbers having count of unique adjacent differences equal to KGiven two positive integers N and K, the task is to construct a permutation of the first N natural numbers such that all possible absolute differences between adjacent elements is K.Examples:Input: N = 3, K = 1Output: 1 2 […]