/* Largest proper divisor of n (Rosetta code) in Picat. http://rosettacode.org/wiki/Largest_proper_divisor_of_n """ a(1) = 1; for n > 1, a(n) = largest proper divisor of n, where n < 101 . """ This program was created by Hakan Kjellerstrand, hakank@gmail.com See also my Picat page: http://www.hakank.org/picat/ */ main => go. go ?=> foreach(I in 1..100) printf("%2d%s",a(I), cond(I mod 10 == 0,"\n", " ")) end, nl. a(1) = 1. a(N) = Div => a(N,N//2,Div). a(N,I,I) :- N mod I == 0. a(N,I,Div) :- a(N,I-1,Div).