Sunidhi Bansal has Published 1085 Articles

Print the kth common factor of two numbers

Sunidhi Bansal

Sunidhi Bansal

Updated on 30-Jul-2019 22:30:26

331 Views

Given with two numbers x and y the output should contain their kth common factor.Input: x=9 y=18 k=1 Output : k common factor = 2 Factors of 9 : 1, 3, 9 Factors of 18 : 1, 2, 3, 6, 9, 18 Greatest Common Factor : 9AlgorithmSTART Step 1 -: ... Read More

Print n terms of Newman-Conway Sequence

Sunidhi Bansal

Sunidhi Bansal

Updated on 30-Jul-2019 22:30:26

394 Views

Newman-Conway Sequence is used for generating following integer sequence.1 1 2 2 3 4 4 4 5 6 7 7 8 8 8 8 9 10 11 12Formula used for generating Newman-Conway sequence for n numbers is −P(n) = P(P(n - 1)) + P(n - P(n - 1)) Where, p(1) ... Read More

Print n smallest elements from given array in their original order

Sunidhi Bansal

Sunidhi Bansal

Updated on 30-Jul-2019 22:30:26

252 Views

Given with array of let’s say k elements the program must find the n smallest elements amongst them in their appearing order.Input : arr[] = {1, 2, 4, 3, 6, 7, 8}, k=3 Ouput : 1, 2, 3 Input k is 3 it means 3 shortest elements among the set ... Read More

Print values of ‘a’ in equation (a+b) <= n and a+b is divisible by x

Sunidhi Bansal

Sunidhi Bansal

Updated on 30-Jul-2019 22:30:26

112 Views

Given with equation program must find the value of ‘a’ where a+b Declare start variables b=10, x=9, n=40 and flag=0, divisible Step 2 -> Loop For divisible = (b / x + 1 ) * x and divisible = 1       Print divisible-1       Set flag=1 ... Read More

Print the given pattern recursively

Sunidhi Bansal

Sunidhi Bansal

Updated on 30-Jul-2019 22:30:26

4K+ Views

Here, as per the given problem pattern needs to be displayed using recursive approach.Recursive function is the one that calls itself n number of times. There can be ‘n’ number of recursive function in a program. The problem working with recursive function is their complexity.AlgorithmSTART Step 1 -> function int ... Read More

Advertisements