C Search for non-occurring pairwise differences C between any 2 terms in sequences OEIS A005282 (Mian-Chowla), C A051788 (Variant starting with 1,3 instead of 1,2) C A058335 (Variant starting with 1,4 instead of 1,2) C Check idea of Jens Voss posted in seqfan mailing list C on Feb 4 2003. C C Hugo Pfoertner, http://www.pfoertner.org/ C C Version history: C C 02.03.2003 Merge with special program to create A080933 C 21.02.2003 Derived program to search for first term of C sequences A080200, A080201, A080932 and extensions C 07.02.2003 Determine record setting differences between C adjacent elements of the generalized (1,n) M-C sequences C 05.02.2003 Initial version C C INTEGER M, DD, DINC, N2 C M=400000 seems sufficient to create the first terms of A080933 C M=4000000 was used for A080200, A080201, A080932 PARAMETER (M=400000,M2=M+M) INTEGER S(2000),T(M2),D(M) C Loop over 2nd sequence term of generalized M-C sequence C starting with 1,N2,... C To create sequence A080933 activate all lines in C blocks CA080933BEGIN .. CA080933END CA080933BEGIN C DO 200 N2 = 2, 20 CA080933END C Special one term loops to create OEIS sequences C A005282, A080200, A080222 DO 200 N2 = 2, 2 C A051788, A080201, A080223 C DO 200 N2 = 3, 3 C A058335, A080932, A080931 C DO 200 N2 = 4, 4 C DO 10 I = 1, M2 T(I) = I 10 CONTINUE DO 15 I = 1, M D(I) = I 15 CONTINUE L = 2 S(1) = 1 C Initial value for generalized variant starting with 1, n S(2) = N2 T(S(2)-S(1)) = 0 C C LOOPS OVER ALL DIFFERENCES BETWEEN ELEMENTS ALREADY FOUND 100 CONTINUE DO 20 I = 1, L DO 30 J = I+1, L DD = S(J) - S(I) D(DD) = 0 C ELIMINATE ELEMENTS THAT HAVE ALREADY COVERED DIFFERENCES DO 40 K = 2, L N = S(K) + DD T(N) = 0 40 CONTINUE 30 CONTINUE 20 CONTINUE C C SEARCH FOR NEXT CANDIDATE L = L + 1 DO 50 I = S(L-1), M IF ( T(I) .NE. 0 ) THEN S(L) = I C C To watch how the smallest non-occurring difference is C evolving, active lines from CWATCHDIFBEGIN until CWATCHDIFEND C The second item in the output line are the Mian-Chowla (1,n) C sequence terms (n=1:A005282, n=2:A051788, n=3:A058335) C CWATCHDIFBEGIN C do 51 j = 1, 100 C if ( d(j) .ne. 0 ) then C WRITE (*,*) L, I, d(j) C GOTO 100 C endif C51 continue CWATCHDIFEND GOTO 100 ENDIF 50 CONTINUE C Differences covered so far: DO 70 I = 1, 400 IF ( D(I) .NE. 0 ) THEN WRITE (*,1000) N2, D(I) WRITE (10,1000) N2, D(I) 1000 FORMAT ( I7, I4 ) C If only smallest non-occurring difference is required, C terminated loop after first hit CA080933BEGIN C GOTO 200 CA080933END ENDIF 70 CONTINUE C C To determine the maximum differences of consecutive elements C the commented code lines from CMAXDIFBEGIN until CMAXDIFEND C has to be activated C CMAXDIFBEGIN J = 0 DINC = 0 DO 80 I = 2, L DD = S(I) - S(I-1) IF ( DD .GT. DINC ) THEN DINC = DD C The last item in the output line is used for OEIS C A080222, A080223, A080931 WRITE (11,1001) I, S(I-1), S(I), DD 1001 FORMAT ( I4, 2I8, I6 ) ENDIF 80 CONTINUE CMAXDIFEND C 200 CONTINUE END