दो संख्याएं x और y दी गई हैं, आउटपुट में उनका kवां सामान्य गुणनखंड होना चाहिए।
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 : 9
एल्गोरिदम
START Step 1 -: take input as x and y lets say 3 and 21 and k as 1 Step 2 -: declare start variables as int i,num,count=1 Step 3 -: IF xउदाहरण
#includeint main() { int x = 3, y = 21, k = 1; // taking x and y as two number and k is limit for their common factor int i,num,count=1; if(x आउटपुट
यदि हम उपरोक्त प्रोग्राम चलाते हैं तो यह निम्नलिखित आउटपुट उत्पन्न करेगा।
their kth common factor is : 2