All about flooble | fun stuff | Get a free chatterbox | Free JavaScript | Avatars    
perplexus dot info

Home > Numbers
All(?) about SEQ (Posted on 2012-12-19) Difficulty: 4 of 5
5, 10, 13, 17, 20, 25 ... are numbers that are the sum of 2 distinct nonzero squares (A004431-let's call it SEQ).

Now, some tasks for you:

1. 25,40,52,73,89 ...; add 2 more numbers in this sequence.
2. In the sequence SEQ find the 1st appearance of 3 consecutive numbers.
3. Find the index of the 1st 4-digit member in SEQ.
4. There is a "run" of 4 consecutive non members of SEQ between 45 and 50 .
a) find a longer "run".
b) find the longest "run" within the 1st 12000 members of SEQ.
5. Find the lowest pandigital member of SEQ.
6. Find a pandigital member(s?) of SEQ, equalling A2+ B2 such that the concatenation of the numbers A & B is also pandigital.

Rem: If you have solved 4 or more out of 6 listed tasks please rate this post - I've spent about 2.5 hours to create it.

No Solution Yet Submitted by Ady TZIDON    
Rating: 5.0000 (2 votes)

Comments: ( Back to comment list | You must be logged in to post comments.)
Solution solutions Comment 1 of 1

The program runs rapidly, as to test a given number, it merely tests a=1 through the square root of half n. Then subtracting its square from n the difference has to be a perfect square to be in SEQ:

DEFDBL A-Z
DIM seq(40), nseq(40)
OPEN "aboutseq.txt" FOR OUTPUT AS #2
CLS
FOR n = 1 TO 50000
  flag = 0
  FOR a = 1 TO SQR(n / 2)
    n1 = a * a
    n2 = n - n1
    sr = INT(SQR(n2) + .5)
    IF sr * sr = n2 AND n2 <> n1 THEN
      index = index + 1
      IF index = 7 THEN PRINT n; : PRINT #2, n;
      IF index = 8 THEN PRINT n: PRINT #2, n
      IF n > 999 AND flag4 = 0 THEN PRINT index; n: PRINT #2, index; n: flag4 = 1
      flag = 1
      EXIT FOR
    END IF
  NEXT a
  IF flag THEN
     IF nseqct >= 4 THEN
       PRINT "ns"; nseqct;
       PRINT #2, "ns"; nseqct;
       FOR i = 1 TO nseqct: PRINT nseq(i); : PRINT #2, nseq(i); : NEXT: PRINT : PRINT #2,
       IF nseqct > maxnseqct THEN
         maxnseqct = nseqct
         maxnseqstart = n - nseqct
       END IF
     END IF
     seqct = seqct + 1: nseqct = 0
     seq(seqct) = n
   ELSE
     IF seqct >= 3 THEN
       PRINT "s"; seqct;
       PRINT #2, "s"; seqct;
       FOR i = 1 TO seqct: PRINT seq(i); : PRINT #2, seq(i); : NEXT: PRINT : PRINT #2,
       IF seqct > maxseqct THEN
         maxseqct = seqct
         maxseqstart = n - seqct
         maxseqstartindex = index - seqct + 1
       END IF
     END IF
     nseqct = nseqct + 1: seqct = 0
     nseq(nseqct) = n
  END IF

NEXT n
PRINT index
PRINT maxseqstartindex, maxseqstart, maxseqct
PRINT maxnseqstart, maxnseqct
PRINT #2, index
PRINT #2, maxseqstartindex, maxseqstart, maxseqct
PRINT #2, maxnseqstart, maxnseqct
CLOSE

 

The start of the output is:

ns 4  1  2  3  4 
ns 4  6  7  8  9
ns 4  21  22  23  24
 26  29
ns 4  30  31  32  33
ns 4  46  47  48  49
ns 4  54  55  56  57
ns 4  69  70  71  72
ns 5  75  76  77  78  79
ns 6  91  92  93  94  95  96
ns 4  118  119  120  121
ns 4  126  127  128  129
ns 5  131  132  133  134  135
ns 7  138  139  140  141  142  143  144
ns 4  165  166  167  168
ns 4  174  175  176  177
ns 7  186  187  188  189  190  191  192
ns 5  213  214  215  216  217
s 3  232  233  234
ns 6  235  236  237  238  239  240
ns 4  246  247  248  249
ns 6  251  252  253  254  255  256
ns 7  282  283  284  285  286  287  288
ns 6  299  300  301  302  303  304
ns 6  307  308  309  310  311  312
ns 4  321  322  323  324
ns 4  329  330  331  332
ns 5  341  342  343  344  345
ns 8  378  379  380  381  382  383  384  385
ns 4  390  391  392  393
ns 5  411  412  413  414  415
ns 4  417  418  419  420
ns 7  426  427  428  429  430  431  432
ns 5  437  438  439  440  441
ns 4  453  454  455  456
ns 8  469  470  471  472  473  474  475  476
ns 6  494  495  496  497  498  499
ns 4  501  502  503  504
ns 4  510  511  512  513
ns 5  515  516  517  518  519
s 3  520  521  522
ns 7  523  524  525  526  527  528  529

showing:

1. The next two numbers in the sequnce are 26 and 29.

2. The first occurrence of 3 consecutive numbers in SEQ is
       232  233  234

3. See below.
      
4a. Several runs of 7 and 8 non-members (marked ns, for non-sequence, with the length of each such sequence) appear above.

Later on, the line

 293  1000
 
shows:

3. The first 4-digit number in SEQ, 1000, has index 293.

At the bottom of the listing:
 70            232           3
 31658         23
 
indicates:

4b. The longest run of members (marked with s) is only 3. ... of non-members is 23, beginning with 31658. (The highest index found among members was 12262 which in fact was the 50,000, the last number checked, so the non-member sequence starting at 31,658 was indeed within the 12,000 member set specified in the puzzle.)

For the pandigital questions we use another program:


DECLARE SUB permute (a$)
DEFDBL A-Z
CLS
a$ = "123456789": h$ = a$
DO
  n = VAL(a$)
  FOR a = 1 TO SQR(n / 2)
    n1 = a * a
    n2 = n - n1
    sr = INT(SQR(n2) + .5)
    IF sr * sr = n2 THEN PRINT a$, n1, n2: ct = ct + 1: EXIT FOR
  NEXT a
  IF ct > 5 THEN GOTO after
  permute a$
LOOP UNTIL a$ = h$
after:
PRINT
ct = 0
a$ = "1234567890": h$ = a$
DO
  n = VAL(a$)
  FOR a = 1 TO SQR(n / 2)
    n1 = a * a
    n2 = n - n1
    sr = INT(SQR(n2) + .5)
    IF sr * sr = n2 THEN
     PRINT a$, n1, n2: ct = ct + 1: EXIT FOR
    END IF
  NEXT a
  IF ct > 5 THEN GOTO after2
  permute a$
LOOP UNTIL a$ = h$
after2:
PRINT : ct = 0
a$ = "123456789": h$ = a$
DO
  n = VAL(a$)
  FOR a = 1 TO SQR(n / 2)
    n1 = a * a
    n2 = n - n1
    sr = INT(SQR(n2) + .5): n1s = n1: n2s = n2
    IF sr * sr = n2 THEN
      tst$ = LTRIM$(STR$(a)) + LTRIM$(STR$(sr))
      IF LEN(tst$) = 9 THEN
        good = 1
        FOR i = 1 TO 9
          IF INSTR(tst$, MID$("123456789", i, 1)) = 0 THEN good = 0: EXIT FOR
        NEXT i
        IF good THEN PRINT n, a; sr: ct = ct + 1
      END IF
    END IF
  NEXT a
  IF ct > 5 THEN GOTO after3
  permute a$
LOOP UNTIL a$ = h$
after3:
PRINT : ct = 0
a$ = "1234567890": h$ = a$
DO
  n = VAL(a$)
  FOR a = 1 TO SQR(n / 2)
    n1 = a * a
    n2 = n - n1
    sr = INT(SQR(n2) + .5): n1s = n1: n2s = n2
    IF sr * sr = n2 THEN
      tst$ = LTRIM$(STR$(a)) + LTRIM$(STR$(sr))
      IF LEN(tst$) = 10 THEN
        good = 1
        FOR i = 1 TO 10
          IF INSTR(tst$, MID$("1234567890", i, 1)) = 0 THEN good = 0: EXIT FOR
        NEXT i
        IF good THEN PRINT n, a; sr: ct = ct + 1
      END IF
    END IF
  NEXT a
  IF ct > 5 THEN GOTO after4
  permute a$
LOOP UNTIL a$ = h$

after4:

END

finds

The first few pandigital members of SEQ (without and with zeros):

a^2 + b^2         a^2            b^2
123456978      27279729      96177249
123457689      4473225       118984464
123457869      580644        122877225
123458976      55890576      67568400
123465789      4284900       119180889
123468957      5659641       117809316
1234569780     34363044      1200206736
1234570698     2350089       1232220609
1234570896     32400         1234538496
1234576089     595750464     638825625
1234576890     670761        1233906129
1234578609     125888400     1108690209

and the pandigital members whose a and b concatenate pandigitally:

 a^2 + b^2      a      b
 175236849     3495  12768
 179684325     3654  12897
 189237465     4536  12987
 197485632     5376  12984
 218367945     5469  13728
 231649785     6528  13749
 1238497065    17628  30459
 1239785640    16782  30954
 1325479860    19482  30756
 1328596740    19842  30576
 1348657209    16947  32580
 1352879460    17094  32568


 
These four lists would each probably continue further if we hadn't stopped at six each.


  Posted by Charlie on 2012-12-20 01:18:32
Please log in:
Login:
Password:
Remember me:
Sign up! | Forgot password


Search:
Search body:
Forums (0)
Newest Problems
Random Problem
FAQ | About This Site
Site Statistics
New Comments (0)
Unsolved Problems
Top Rated Problems
This month's top
Most Commented On

Chatterbox:
Copyright © 2002 - 2024 by Animus Pactum Consulting. All rights reserved. Privacy Information