- Related Questions & Answers
- Find original numbers from gcd() every pair in C++
- Find original numbers from gcd() every pair in Python
- Print n numbers such that their sum is a perfect square
- Place N^2 numbers in matrix such that every row has an equal sum in C++
- Maximum sum of distinct numbers such that LCM of these numbers is N in C++
- Print all distinct integers that can be formed by K numbers from a given array of N numbers in C++
- Program to print numbers such that no two consecutive numbers are co-prime and every three consecutive numbers are co-prime Using C++
- Find GCD of two numbers
- Maximum value K such that array has at-least K elements that are >= K in C++
- Print numbers with digits 0 and 1 only such that their sum is N in C Program.
- C++ Program to Find the GCD and LCM of n Numbers
- Print all increasing sequences of length k from first n natural numbers in C++
- Find minimum x such that (x % k) * (x / k) == n in C++
- Print direction of moves such that you stay within the [-k, +k] boundary in C++
- Find the GCD of N Fibonacci Numbers with given Indices in C++

- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who

GCD stands for Greatest Common Divisor of two or more integers excluding 0

Like, to find the greatest common divisor of 48 and 180

48 = 2 × 2 × 2 × 2 × 3

180 = 2 × 2 × 3 × 3 × 5

Greatest common divisor = 2 × 2 × 3 = 12.

In the given problem, N lines should be printed with elements have GCD as specified

Input : N=2 GCD=2 Ouput : 2-4-6-10 14-16-18-22

START Step 1 -> take input n(e.g. 2) and k(e.g. 2) as int values and i Step 2-> Loop For i to 0 and i<n and i++ Print (k * (6 * i + 1)) Print (k * (6 * i + 2)) Print (k * (6 * i +3)) Print (k * (6 * i + 5)) Print \n Step 3 -> end loop STOP

#include<stdio.h> int main() { int i,n = 2, k = 2; for (i = 0; i < n; i++) { printf("%d-",(k * (6 * i + 1))); printf("%d-",(k * (6 * i + 2))); printf("%d-",(k * (6 * i + 3))); printf("%d",(k * (6 * i + 5))); printf("\n"); } return 0; }

if we run above program then it will generate following output.

2-4-6-10 14-16-18-22

Advertisements