🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: comp.lang.prolog
Article #2548

Re: 91 function

#2548
From: wup
Date: Thu, 12 Feb 1987 19:31
19 lines
998 bytes
In article <3782@milano.UUCP>, varghese@mcc.com (Joe Varghese) writes:
> ...a Prolog version:
>
> f91(91,91) :- !.
> f91(X,Y) :- X > 111, !, Z is X - 10, f91(Z,W), f91(W,Y).
> f91(X,Y) :- X > 100, !, Z is X - 10, f91(Z,Y).
> f91(X,Y) :- Z is X + 10, f91(Z,W), f91(W,Y).
>

This works only for X=10*N+1 for integer N.  Other cases
the program goes into infinite recursion... try f91(100,Y).
I suppose the third clause should have been

   f91(X,Y) :- X > 100, !, Z is X - 11, f91(Z,Y).

Then it will work...

Peter Y.F. Wu
wup@csv.rpi.edu
Technical Details
Message-ID: <785@rpics.RPI.EDU>
Path: arc1-ca.pugleaf.net!utzoo!watmath!clyde!rutgers!brl-adm!seismo!rpics!wup
References: <3782@milano.UUCP>

Show Full Headers
Complete Article Headers
Relay-Version: version B 2.10 5/3/83; site utzoo.UUCP
Path: arc1-ca.pugleaf.net!utzoo!watmath!clyde!rutgers!brl-adm!seismo!rpics!wup
From: wup@rpics.UUCP
Newsgroups: comp.lang.prolog
Subject: Re: 91 function
Message-ID: <785@rpics.RPI.EDU>
Date: Thu, 12-Feb-87 14:31:55 EST
Article-I.D.: rpics.785
Posted: Thu Feb 12 14:31:55 1987
Date-Received: Fri, 13-Feb-87 23:15:51 EST
References: <3782@milano.UUCP>
Lines: 19
Summary: Bug and Correction...