Você está na página 1de 3

================OPERANDOS IGUALES==================

comenzar:- read(N),
cicloI(N,1).

cicloI(N,I):- I > N ,!.

cicloI(N,I):- I1 is I + 1,
mostrar(I),
cicloI(N, I1).

mostrar(I):- write(I),write(x),
write(I),write(=),
R is I* I,
write(R),nl.

================OPERANDOS DIFERENTES==================

comenzar:- read(N),
cicloI(N,1).

cicloI(N,I):- I > N ,!.

cicloI(N,I):- cicloJ(N,I,1),
I1 is I + 1,
cicloI(N, I1).

cicloJ(N,I,J):- J > N ,!.


cicloJ(N,I,J):- mostrar(I,J),
J1 is J +1,
cicloJ(N,I,J1).

mostrar(I,J):- J=:=I,!.
mostrar(I,J):- write(I),write(x),
write(J),write(=),
R is I* J,
write(R),nl.
================OPERANDOS PARES==================
comenzar:- read(N),
cicloI(N,2).

cicloI(N,I):- I > N ,!.

cicloI(N,I):- I1 is I + 2,
mostrar(I),
cicloI(N, I1).

mostrar(I):- write(I),write(x),
write(I),write(=),
R is I* I,
write(R),nl.

================OPERANDOS AMBOS NO PAR NI IMPAR================


comenzar:- read(N),
cicloI(N,1).

cicloI(N,I):- I > N ,!.

cicloI(N,I):- cicloJ(N,I,1),
I1 is I + 1,
cicloI(N, I1).

cicloJ(N,I,J):- J > N ,!.


cicloJ(N,I,J):- mostrar(I,J),
J1 is J +1,
cicloJ(N,I,J1).

mostrar(I,J):- J=:=I,!.
mostrar(I,J):- I mod 2=:= 0, J mod 2 =:= 0,!.
mostrar(I,J):- I mod 2=:= 1, J mod 2 =:= 1,!.

mostrar(I,J):- write(I),write(x),
write(J),write(=),
R is I* J,
write(R),nl.
================OPERANDOS ASCENDENTE Y DESCENDENTE=============

comenzar:- read(N),
cicloI(N,1,N).

cicloI(N,I,J):- I > N ,!.

cicloI(N,I,J):- J1 is J - 1,
I1 is I + 1,
mostrar(I,J),
cicloI(N, I1,J1).

mostrar(I,J):- write(I),write(x),
write(J),write(=),
R is I* J,
write(R),nl.

================FACTORIAL=============

factorial1(N,F):- factorial(N,1,F).
factorial(N,I,1):- I>=N,!.
factorial(N,I,F):- I1 is I+1,
factorial(N,I1,F1),
F is F1*I1.