This file contains hidden or 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
sum1(0,0). | |
sum1(A,B) :- C is A-1, sum1(C,D), B is A +D. |
This file contains hidden or 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
human(socrates). | |
mortal(X) :- human(X). |
This file contains hidden or 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
wa(0,0). | |
wa(N,Sum) :- M is N - 1, wa(M,Sum2), Sum is Sum2 + N. |
This file contains hidden or 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
f(a). | |
f(b). | |
g(x). | |
g(y). | |
rf :- f(X),write(X),tab(1). | |
rg :- g(X),write(X),tab(1). | |
go2 :- rf,rg,fail. | |
go2. |
This file contains hidden or 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
wa(N,Sum) :- M is N -1, wa(M,Sum2), Sum is Sum2 + N. | |
wa(0,0). |
This file contains hidden or 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
(define (odd n) (if (= (modulo n 2) 1) #t #f)) | |
(define (sum2 n) (if (= n 1) 1 | |
(+ (sum2 (- n 2)) (* n n)))) | |
(define (odd2sum1 n) (if (odd n) (sum2 n) | |
(sum2 (- n 1)))) |
This file contains hidden or 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
odd(X) :- X mod 2 =\= 0. | |
odd2sum1(1,1). | |
odd2sum1(N,Sum) :- odd(N), N2 is N-2,odd2sum1(N2,Sum2),Sum is Sum2 + N*N. | |
odd2sum1(N,Sum) :- N2 is N-1,odd2sum1(N2,Sum). |
This file contains hidden or 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 <cstdio> | |
int main(){ | |
int min,n,k[100]; | |
scanf("%d", &n); | |
for(int i = 0; i < n; i++){ | |
scanf("%d", &k[i]); | |
} |
This file contains hidden or 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
import java.util.*; | |
public class Main { | |
public static void main(String[] args){ | |
Scanner sc = new Scanner(System.in); | |
int indexnum = sc.nextInt(); | |
int[] indexArray; | |
indexArray = new int[indexnum]; |
This file contains hidden or 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 <cstdio> | |
int main(){ | |
int min,n,k[100]; | |
scanf("%d", &n); | |
for(int i = 0; i < n; i++){ | |
scanf("%d", &k[i]); | |
} |
OlderNewer