##R, 91 chars
R, 91 chars
a=scan();n=1;p=5;while(n!=a){p=p+1;q=p-2;if(sum(!p%%2:p,!q%%2:q)<3)n=n+1};cat(q,p,sep=", ") Nothing really fancy:
a=scan() n=1 p=5 while(n!=a){ p=p+1 q=p-2 if(sum(!p%%2:p,!q%%2:q)<3) # Check that p and q are both primes by checking n=n+1 # the number of zeroes resulting from } # p modulo each integers 2 to p and same for q cat(q,p,sep=", ") Usage:
> a=scan();n=1;p=5;while(n!=a){p=p+1;q=p-2;if(sum(!p%%2:p,!q%%2:q)<3)n=n+1};cat(q,p,sep=", ") 1: 10 2: Read 1 item 107, 109