Rare numbers: Difference between revisions

Content deleted Content added
PureFox (talk | contribs)
→‎{{header|Go}}: Some improvements - reduces execution time by about a third.
→‎{{header|REXX}}: regenerated the abpq array by using a larger range that included odd number of digits.
Line 404: Line 404:
parse arg many . /*obtain optional argument from the CL.*/
parse arg many . /*obtain optional argument from the CL.*/
if many=='' | many=="," then many= 5 /*Not specified? Then use the default.*/
if many=='' | many=="," then many= 5 /*Not specified? Then use the default.*/
@g= 2002 2112 2222 2332 2442 2552 2662 2772 2882 2992 4010 4030 4050 4070 4090 4100 4120 ,
@g= 2002 2112 2222 2332 2442 2552 2662 2772 2882 2992 4000 4010 4030 4050 4070 4090 4100 ,
4140 4160 4180 4210 4230 4250 4270 4290 4300 4320 4340 4360 4380 4410 4430 4450 4470 ,
4110 4120 4140 4160 4180 4210 4230 4250 4270 4290 4300 4320 4340 4360 4380 4410 4430 ,
4490 4500 4520 4540 4560 4580 4610 4630 4650 4670 4690 4700 4720 4740 4760 4780 4810 ,
4440 4450 4470 4490 4500 4520 4540 4560 4580 4610 4630 4650 4670 4690 4700 4720 4740 ,
4830 4850 4870 4890 4900 4920 4940 4960 4980 6010 6015 6030 6035 6050 6055 6070 6075 ,
4760 4780 4810 4830 4850 4870 4890 4900 4920 4940 4960 4980 4990 6010 6015 6030 6035 ,
6090 6095 6100 6105 6120 6125 6140 6145 6160 6165 6180 6185 6210 6215 6230 6235 6250 ,
6050 6055 6070 6075 6090 6095 6100 6105 6120 6125 6140 6145 6160 6165 6180 6185 6210 ,
6255 6270 6275 6290 6295 6300 6305 6320 6325 6340 6345 6360 6365 6380 6385 6410 6415 ,
6215 6230 6235 6250 6255 6270 6275 6290 6295 6300 6305 6320 6325 6340 6345 6360 6365 ,
6430 6435 6450 6455 6470 6475 6490 6495 6500 6505 6520 6525 6540 6545 6560 6565 6580 ,
6380 6385 6410 6415 6430 6435 6450 6455 6470 6475 6490 6495 6500 6505 6520 6525 6540 ,
6585 6610 6615 6630 6635 6650 6655 6670 6675 6690 6695 6700 6705 6720 6725 6740 6745 ,
6545 6560 6565 6580 6585 6610 6615 6630 6635 6650 6655 6670 6675 6690 6695 6700 6705 ,
6760 6765 6780 6785 6810 6815 6830 6835 6850 6855 6870 6875 6890 6895 6900 6905 6920 ,
6720 6725 6740 6745 6760 6765 6780 6785 6810 6815 6830 6835 6850 6855 6870 6875 6890 ,
6925 6940 6945 6960 6965 6980 6985 8007 8008 8017 8027 8037 8047 8057 8067 8077 8087 ,
6895 6900 6905 6920 6925 6940 6945 6960 6965 6980 6985 8007 8008 8017 8027 8037 8047 ,
8092 8097 8107 8117 8118 8127 8137 8147 8157 8167 8177 8182 8187 8197 8228 8272 8297 ,
8057 8067 8077 8087 8092 8097 8107 8117 8118 8127 8137 8147 8157 8167 8177 8182 8187 ,
8338 8362 8387 8448 8452 8477 8542 8558 8567 8632 8657 8668 8722 8747 8778 8812 8837 ,
8197 8228 8272 8297 8338 8362 8387 8448 8452 8477 8542 8558 8567 8632 8657 8668 8722 ,
8888 8902 8927 8998; @g#= words(@g) /*4 digit abutted numbers for AB and PQ*/
8747 8778 8812 8837 8888 8902 8927 8998 /*4 digit abutted numbers for AB and PQ*/
@g#= words(@g)
/* [↓]─────────────────boolean arrays are used for checking for digit presence.*/
/* [↓]─────────────────boolean arrays are used for checking for digit presence.*/
@dr.=0; @dr.2= 1; @dr.5=1 ; @dr.8= 1; @dr.9= 1 /*rare # must have these digital roots.*/
@dr.=0; @dr.2= 1; @dr.5=1 ; @dr.8= 1; @dr.9= 1 /*rare # must have these digital roots.*/
@ps.=0; @ps.2= 1; @ps.3= 1; @ps.7= 1; @ps.8= 1 /*perfect squares must end in these.*/
@ps.=0; @ps.2= 1; @ps.3= 1; @ps.7= 1; @ps.8= 1 /*perfect squares must end in these.*/
@149.=0; @149.1=1; @149.4=1; @149.9=1 /*values for Z that need an even Y. */
@149.=0; @149.1=1; @149.4=1; @149.9=1 /*values for Z that need an even Y. */
@odd.=0; do i=-9 by 2 to 9; @odd.i=1; end /* " " N " " " " A. */
@odd.=0; do i=-9 by 2 to 9; @odd.i=1 /* " " N " " " " A. */
end /*i*/
@gen.=0; do i=1 for @g#; parse value word(@g,i) with a 2 b 3 p 4 q; @gen.a.b.p.q= 1; end
@gen.=0; do i=1 for words(@g); parse value word(@g,i) with a 2 b 3 p 4 q; @gen.a.b.p.q=1
/*# AB···PQ could be a good rare value*/
evenN= \ (10 // 2) /*initial value for evenness of N. */
/*# AB···PQ could be a good rare value*/
end /*i*/
div9= 9 /*dif must be ÷ 9 when N has even #digs*/
div9= 9 /*dif must be ÷ 9 when N has even #digs*/
evenN= \ (10 // 2) /*initial value for evenness of N. */
#= 0 /*the number of rare numbers (so far)*/
#= 0 /*the number of rare numbers (so far)*/
do n=10 /*Why 10? All 1 dig #s are palindromic*/
do n=10 /*Why 10? All 1 dig #s are palindromic*/