domains
N,Sum,T,T1,A=integer
predicates
go
armstrng(N,Sum,A)
Chk(Sum,A)
clauses
go:-
write("Enter
the value of N :"),nl,
readint(N),
A=N,
Sum=0,
armstrng(N,Sum,A).
armstrng(N,Sum,A):-
N>0,
T=N
mod 10,
T1=T*T*T,
Sum1=Sum+T1,
N1=N/10,
N2=N1-0.5,
armstrng(N2,Sum1,A).
armstrng(_,Sum,A):-
chk(Sum,A).
chk(Sum,A):-
Sum=A,
write("Number
is Armstrong."),nl.
chk(_,_):-
write("Number
is not Armstrong."),nl.

No comments:
Post a Comment