20_09

Write a Prolog program to implement GCD of two numbers.

 Source Code :

 

gcd(X,0,X).

gcd(X,Y,Z):-

    R is mod(X,Y),

    gcd(Y,R,Z).

 

Output :

 

Prolog program to implement GCD of two numbers

No comments:

Post a Comment

Write a program in C to convert a decimal number to binary using recursion.

 Source code: //Write a program in C to convert a decimal number to binary using recursion. #include<stdio.h> long convertB_to_D(int d...