যাই হোক, পোস্ট করে দিলাম কারো যদি সামান্য হেল্প হয়।
Code:
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include<stdio.h> | |
int main() | |
{ | |
int a,b,c,i,j,temp,temp1; | |
while(scanf("%d %d",&a,&b)==2){ | |
if(a<b){ | |
temp1=a; | |
a=b; | |
b=temp1; // b get the value of a just swapped | |
} | |
while(a%b!=0){ | |
temp=a; | |
a=b; | |
b=temp%b; | |
} | |
printf("%d\n",b); | |
temp=0; | |
} | |
return 0; | |
} |
GCD বের করার পর LCM বের করা একদম সহজ ।
Code :
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include<stdio.h> | |
int main() | |
{ | |
int a,b,a1,b1,n,mul; | |
while(scanf("%d %d",&a,&b)==2){ | |
a1=a; | |
b1=b; | |
mul=a1*b1; | |
if(b>a){ | |
n=a; | |
a=b; | |
b=n; | |
} | |
while(a%b!=0){ | |
n=a; | |
a=b; | |
b=n%b; | |
} | |
printf("GCD : %d\n",b); | |
printf("LCM : %d\n",mul/b); | |
} | |
} |
নিচের ডাউনলোড লিঙ্কে একটা লেখা আছে পড়ে ফেলতে পারেন তবে আগেই বলে রাখি লেখাটা আমার লেখা নয়
এই ওয়েবসাইট থেকে নেয়া, https://binaryrongo.wordpress.com/2013/08/07/gcd-and-lcm/
ডাউনলোড