Created
July 20, 2022 19:25
-
-
Save freakflames29/2c6d032a6b3c0866a9d0ad648c4f0c63 to your computer and use it in GitHub Desktop.
aiis
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
add(A,B):-read(A),read(B),C is A**B,write('SUM IS'),write(C). | |
unary(A):-B is sqrt(A),write(B). | |
circle(R):-A is 3.14*R*R,write(A). | |
triangle(A,B,C):-S is (A+B+C)/2,AR is sqrt(S*(S-A)*(S-B)*(S-C)),write(AR). | |
ctof(T):- F is (T*(9/5))+32,write(F). | |
max(A,B,C):-( A>=B-> (A>=C-> M=A;M=C);(B>=C-> M=B;M=C)),write(M). | |
min(A,B,C):-( A=<B-> ( A=<C-> M is A;M is C);( B=<C-> M is B;M is C)),write(M). | |
leapyr(Y):-write('Enter year'),read(Y),(Y mod 100=:=0-> (Y mod 400=:=0->write('LeapYear');write('Not LeapYear')) ; (Y mod 4=:=0->write('LeapYear');write('Not LeapYear')) ). | |
leap(Y):-( Y mod 100=:=0-> ( Y mod 400=:=0-> write('LEAP');write('NOT LEAP'));( Y mod 4=:=0-> write('LEAP');write('NOT LEAP'))). | |
fact(0,1). | |
fact(N,F):-N >0,N1 is N-1,fact(N1,F1),F is N*F1. | |
sum(0,0). | |
sum(1,1). | |
sum(N,S):-N>=1,N1 is N-1,sum(N1,S1),S is N+S1. | |
gcd(X,Y,G):-( X=:=Y->G is X);( X<Y-> Y1 is Y-X,gcd(X,Y1,G));( X>Y-> gcd(Y,X,G)). | |
len([],0). | |
len([_|T],N):- len(T,N1),N is N1+1. | |
lcm(X,Y,G):-gcd(X,Y,G1),G is X*Y//G1. |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment