Program to add two polynomialsGiven two polynomials represented by two arrays, write a function that adds given two polynomials. Example: Input: A[] = {5, 0, 10, 6} B[] = {1, 2, 4} Output: sum[] = {6, 2, 14, 6} The first input array represents "5 + 0x^1 + 10x^2 + 6x^3" The second array represents "1 + 2x^1 + 4x^2" And Output is
15+ min read
Find number of solutions of a linear equation of n variablesGiven a linear equation of n variables, find number of non-negative integer solutions of it. For example, let the given equation be "x + 2y = 5", solutions of this equation are "x = 1, y = 2", "x = 5, y = 0" and "x = 3, y = 1". It may be assumed that all coefficients in given equation are positive i
10 min read
Number of non-negative integral solutions of a + b + c = nGiven a number n, find the number of ways in which we can add 3 non-negative integers so that their sum is n.Examples : Input : n = 1 Output : 3 There are three ways to get sum 1. (1, 0, 0), (0, 1, 0) and (0, 0, 1) Input : n = 2 Output : 6 There are six ways to get sum 2. (2, 0, 0), (0, 2, 0), (0, 0
7 min read
Generate Pythagorean TripletsGiven a positive integer limit, your task is to find all possible Pythagorean Triplet (a, b, c), such that a <= b <= c <= limit.Note: A Pythagorean triplet is a set of three positive integers a, b, and c such that a2 + b2 = c2. Input: limit = 20Output: 3 4 5 5 12 13 6 8 10 8 15 17 9 12 15 1
14 min read