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

Home > Numbers
Poor primes (Posted on 2015-05-04) Difficulty: 2 of 5
101 is the smallest prime whose sum of the digits i.e. 2 is less than the number of its digits (3).

Compile a list of all primes below 10^10 with this feature.

No Solution Yet Submitted by Ady TZIDON    
No Rating

Comments: ( Back to comment list | You must be logged in to post comments.)
Solution computer solution Comment 1 of 1
        101
      10111
      20011
      20101
      21001
     100003
     100103
     101021
     101111
     102001
     102101
     103001
     120011
     121001
     200003
     200201
     201011
     201101
     202001
     210011
     210101
    1000003
    1000121
    1000211
    1001003
    1002101
    1003001
    1010003
    1010201
    1011001
    1020001
    1020011
    1020101
    1021001
    1100101
    1102001
    1120001
    1201001
    2000003
    2001101
    2002001
    2020001
    2100001
    2100011
    2110001
    3001001
    3010001
   10000103
   10000121
   10000141
   10000303
   10001203
   10001221
   10001311
   10001401
   10002121
   10003001
   10003003
   10010023
   10010101
   10010113
   10010311
   10010401
   10011013
   10011101
   10011121
   10011301
   10012001
   10012021
   10012111
   10013011
   10020013
   10020103
   10020121
   10021001
   10021003
   10021111
   10022011
   10023001
   10030003
   10040011
   10100011
   10100113
   10100131
   10100201
   10100221
   10101101
   10102003
   10102201
   10103011
   10110011
   10111001
   10112101
   10113001
   10120021
   10120111
   10130101
   10140001
   10200011
   10200101
   10200301
   10201001
   10203001
   10210111
   10220011
   10220101
   10300201
   10301101
   10310101
   11000111
   11000113
   11000401
   11001013
   11001031
   11001103
   11001301
   11002001
   11003011
   11010211
   11011003
   11011201
   11012011
   11020001
   11020003
   11021011
   11030011
   11100013
   11100101
   11100121
   11110111
   11110201
   11111101
   11130001
   11200001
   11201101
   11210011
   11300101
   12001001
   12001021
   12001111
   12010021
   12021001
   12100003
   12100111
   12100201
   12102001
   12110101
   12120001
   12200011
   13000201
   13001101
   13200001
   20000003
   20000023
   20000221
   20000311
   20001001
   20001031
   20001301
   20002201
   20004001
   20011001
   20012011
   20012101
   20020001
   20030011
   20101001
   20101201
   20111011
   20130001
   20200111
   20201101
   20210101
   20211001
   20300011
   20300101
   20310001
   21000103
   21000121
   21001021
   21002101
   21003001
   21010111
   21020011
   21021001
   21030001
   21100003
   21100021
   22000001
   22000003
   22000021
   22000201
   22001101
   22011001
   22110001
   22200001
   23000011
   23000101
   23100001
   24000001
   30000001
   30000301
   30001003
   30001201
   30010021
   30011101
   30100003
   30100111
   30100201
   30200011
   30210001
   31000003
   31002001
   31020001
   31100011
   31100101
   32000011
   32001001
   32010001
   33000001
   40000003
   40000021
   40010011
   40010101
   40011001
   41000101
   41001001
   50000101
   50010001
  100000007
  100000123
  100000213
  100000223
  100000231
  100000421
  100001131
  100001203
  100001303
  100002011
  100002013
  100002031
  100002103
  100002113
  100003021
  100003301
  100005001
  100010021
  100010023
  100010033
  100010051
  100010203
  100010231
  100010321
  100010401
  100011031
  100011113
  100011203
  100012103
  100012111
  100012301
  100013021
  100020023
  100020103
  100020113
  100020121
  100020131
  100021003
  100021121
  100022003
  100022201
  100023101
  100030001
  100030121
  100031003
  100031011
  100031101
  100032011
  100040011
  100040201
  100042001
  100050001
  100050101
  100060001
  100100051
  100100111
  100100401
  100101013
  100101041
  100101121
  100101203
  100101401
  100102021
  100103111
  100105001
  100110013
  100110041
  100110121
  100111001
  100111003
  100112101
  100113001
  100113011
  100120003
  100121011
  100121111
  100121201
  100130003
  100131001
  100131011
  100140011
  100200011
  100200013
  100200031
  100200301
  100201103
  100201201
  100201301
  100202101
  100203001
  100210001
  100211021
  100211101
  100220101
  100221101
  100230001
  100300001
  100300121
  100310003
  100330001
  100401011
  100401101
  100500011
  101000023
  101000051
  101000113
  101000203
  101000231
  101000311
  101000401
  101001001
  101001011
  101001013
  101001041
  101002021
  101002103
  101002301
  101003101
  101004011
  101005001
  101010031
  101010113
  101011013
  101011121
  101011301
  101020111
  101021003
  101030021
  101030101
  101040001
  101100011
  101100113
  101100211
  101101103
  101101111
  101102003
  101102101
  101103001
  101110013
  101110201
  101111011
  101111111
  101120021
  101121011
  101130101
  101201003
  101210101
  101220001
  101230001
  101300201
  101301001
  101320001
  102000023
  102000131
  102000401
  102001121
  102001201
  102002003
  102010301
  102013001
  102020021
  102021001
  102100001
  102100003
  102100111
  102100211
  102100301
  102110101
  102110111
  102120001
  102120101
  102200011
  102200101
  102201101
  102300001
  102310001
  103000111
  103000201
  103000301
  103001201
  103010003
  103020011
  103021001
  103101001
  103110011
  103120001
  103200101
  103201001
  104000011
  104000021
  104000201
  104002001
  104101001
  104110001
  105000001
  106000001
  110000201
  110000221
  110000411
  110001131
  110001211
  110001301
  110002003
  110002103
  110002111
  110002201
  110002301
  110003011
  110004001
  110005001
  110010013
  110010031
  110010101
  110010113
  110010301
  110010401
  110011103
  110012011
  110020003
  110020301
  110021011
  110021111
  110030201
  110032001
  110040101
  110050001
  110100013
  110100113
  110100121
  110100203
  110100401
  110101001
  110101003
  110102021
  110110201
  110111011
  110111021
  110111201
  110113001
  110120011
  110130001
  110131001
  110200021
  110200121
  110200201
  110201011
  110201101
  110201111
  110202101
  110212001
  110220101
  110300011
  110301001
  110301011
  110400001
  111000031
  111000101
  111000103
  111000401
  111001001
  111001003
  111001201
  111002201
  111003001
  111004001
  111010013
  111010111
  111020003
  111020111
  111030001
  111102011
  111200003
  111201011
  111210101
  111300001
  112000111
  112001011
  112010011
  112010021
  112010201
  112021001
  112100111
  112100201
  112110001
  112200001
  113001011
  114000001
  114000101
  120000031
  120000103
  120000121
  120000203
  120000301
  120000311
  120001001
  120001111
  120001121
  120001201
  120002021
  120002111
  120003001
  120003011
  120003101
  120010201
  120010211
  120012001
  120013001
  120020011
  120020111
  120021101
  120040001
  120100003
  120100103
  120101011
  120102001
  120110201
  120130001
  120200011
  120202001
  120210001
  120210011
  121000003
  121000211
  121000301
  121002001
  121011101
  121030001
  121100003
  121100011
  121101011
  121102001
  121200011
  122000003
  122001001
  122001101
  122020001
  123000011
  124000001
  130000001
  130001111
  130002001
  130010201
  130020101
  130030001
  130100101
  130102001
  131000021
  131001011
  132000101
  133000001
  140010001
  140200001
  150000001
  150010001
  200000033
  200000051
  200000123
  200000131
  200000201
  200000221
  200000321
  200001001
  200001013
  200001103
  200001211
  200002301
  200003003
  200004001
  200010011
  200010121
  200010211
  200010301
  200010311
  200011211
  200012003
  200012201
  200013001
  200020031
  200020103
  200020211
  200021011
  200023001
  200030101
  200030111
  200031001
  200031011
  200040011
  200040101
  200100031
  200101003
  200102003
  200102011
  200102101
  200103011
  200110103
  200111011
  200120201
  200121001
  200130101
  200140001
  200200003
  200200031
  200210111
  200211101
  200220001
  200230001
  200300003
  200301001
  201000211
  201000301
  201002111
  201010001
  201011003
  201012101
  201020011
  201020101
  201020201
  201021101
  201100001
  201100013
  201101003
  201102001
  201102101
  201110201
  201121001
  201130001
  201300101
  202000003
  202000021
  202001003
  202002001
  202010021
  202011011
  202012001
  202110101
  202111001
  202200001
  203000101
  203000201
  203010001
  203010011
  203200001
  204000011
  204001001
  205000001
  210000023
  210000113
  210001003
  210001021
  210001111
  210001301
  210003011
  210004001
  210010001
  210010103
  210010201
  210010301
  210011201
  210020003
  210020101
  210021101
  210030011
  210030101
  210040001
  210100013
  210100211
  210110003
  210110111
  210120101
  210121001
  210210001
  211000021
  211000121
  211001101
  211001201
  211002101
  211010101
  211011011
  211020001
  211021001
  211110101
  211111001
  211200001
  211210001
  212000003
  212000021
  212000101
  212001001
  212010101
  212020001
  212110001
  213000001
  220000013
  220000201
  220010201
  220020011
  220030001
  220110001
  220200011
  220300001
  221010001
  221010011
  221020001
  221100101
  222000101
  222001001
  230000003
  230001011
  230010101
  230100001
  231000101
  231010001
  240000011
  240001001
  240100001
  300000031
  300001001
  300001003
  300001103
  300001211
  300001301
  300003001
  300003101
  300010001
  300010013
  300011021
  300012001
  300012101
  300013001
  300020003
  300020111
  300030001
  300100001
  300100121
  300100301
  300101003
  300101101
  300110011
  300111011
  300111101
  300121001
  300130001
  300200111
  300210101
  300300001
  300310001
  301000013
  301000211
  301001111
  301002001
  301002101
  301010011
  301010201
  301011001
  301100101
  301101001
  301102001
  301110011
  301111001
  301200001
  301300001
  302001001
  302010101
  302100011
  302101001
  302110001
  303000001
  310001011
  310001101
  310001201
  310002101
  310010003
  310010021
  310010201
  310011001
  310020001
  310100101
  310101101
  310200101
  311001011
  311010001
  311010101
  313000001
  320000201
  320100101
  321000011
  321100001
  330000001
  331000001
  400000301
  400001011
  400001101
  400001111
  400001201
  400002011
  400003001
  400010111
  400010201
  400021001
  400100011
  400120001
  400201001
  400210001
  400300001
  401000011
  401001001
  401200001
  403000001
  410000111
  410010001
  410010011
  410020001
  410100101
  411000011
  420000101
  421000001
  500000003
  500000101
  500000201
  500001001
  501001001
  501010001
  510000011
  510001001
  600000001
  700000001
 1000000007
 1000000021
 1000000033
 1000000103
 1000000123
 1000000223
 1000000241
 1000000321
 1000000403
 1000000411
 1000001011
 1000001021
 1000001203
 1000001213
 1000001311
 1000001501
 1000002103
 1000003013
 1000003111
 1000003211
 1000005001
 1000010051
 1000010101
 1000010303
 1000010321
 1000011011
 1000011301
 1000012121
 1000013011
 1000013101
 1000014011
 1000020001
 1000020011
 1000020023
 1000020221
 1000021003
 1000030001
 1000030103
 1000030121
 1000030301
 1000032101
 1000040201
 1000050001
 1000060001
 1000100033
 1000100051
 1000100201
 1000100303
 1000100401
 1000100501
 1000102003
 1000102121
 1000103003
 1000103101
 1000110101
 1000110203
 1000110401
 1000111103
 1000111121
 1000111201
 1000112011
 1000112021
 1000120001
 1000120021
 1000120103
 1000130011
 1000200001
 1000200013
 1000200031
 1000200101
 1000200203
 1000201003
 1000202003
 1000202101
 1000204001
 1000210301
 1000212011
 1000213001
 1000240001
 1000300003
 1000300031
 1000300121
 1000300211
 1000302001
 1000310011
 1000320011
 1000400021
 1000401001
 1000401011
 1000410011
 1000411001
 1000510001
 1000600001
 1001000051
 1001000111
 1001000113
 1001000131
 1001000141
 1001000321
 1001001011
 1001001311
 1001002001
 1001002111
 1001003111
 1001004101
 1001005001
 1001010011
 1001010013
 1001010103
 1001010113
 1001010401
 1001011003
 1001011103
 1001011211
 1001011301
 1001012101
 1001020003
 1001020021
 1001030003
 1001030011
 1001030101
 1001031011
 1001040011
 1001040101
 1001101021
 1001101121
 1001103001
 1001110013
 1001110021
 1001110031
 1001110111
 1001112001
 1001120101
 1001130101
 1001200111
 1001201101
 1001202101
 1001210003
 1001210101
 1001220001
 1001300011
 1001301101
 1001310001
 1002000001
 1002000101
 1002000301
 1002001211
 1002002021
 1002002201
 1002010003
 1002010013
 1002010021
 1002010301
 1002011011
 1002011201
 1002021001
 1002100013
 1002100031
 1002101011
 1002103001
 1002110003
 1002110111
 1002120101
 1002220001
 1003000001
 1003000021
 1003000111
 1003000121
 1003000211
 1003010003
 1003010011
 1003011011
 1003111001
 1004000003
 1004000111
 1004000201
 1004010011
 1004010101
 1004100101
 1004101001
 1004110001
 1005100001
 1006000001
 1010000011
 1010000021
 1010000051
 1010000111
 1010000113
 1010000203
 1010000231
 1010000401
 1010001023
 1010001101
 1010001203
 1010002001
 1010002031
 1010003003
 1010003021
 1010004011
 1010004101
 1010010011
 1010010013
 1010010311
 1010011103
 1010011111
 1010012021
 1010020003
 1010021021
 1010030011
 1010040001
 1010050001
 1010100011
 1010100103
 1010100121
 1010102011
 1010102021
 1010102101
 1010104001
 1010110001
 1010110103
 1010110201
 1010111111
 1010113001
 1010120011
 1010120101
 1010130101
 1010201111
 1010201201
 1010202001
 1010210021
 1010212001
 1010221001
 1010300101
 1010300201
 1010301001
 1010301011
 1010310011
 1011000041
 1011000101
 1011001003
 1011001031
 1011001301
 1011003011
 1011003101
 1011010031
 1011010201
 1011010211
 1011021001
 1011030011
 1011030101
 1011040001
 1011100003
 1011100121
 1011110011
 1011110021
 1011200011
 1011201011
 1011301001
 1012000013
 1012000201
 1012001021
 1012001101
 1012001201
 1012002011
 1012010101
 1012010201
 1012021001
 1012030001
 1012101011
 1013000011
 1013000101
 1013011001
 1014000101
 1015000001
 1020000011
 1020000013
 1020000103
 1020000131
 1020000301
 1020001001
 1020001013
 1020001201
 1020002111
 1020002201
 1020010031
 1020020201
 1020022001
 1020030001
 1020030101
 1020100001
 1020100021
 1020101003
 1020101021
 1020102011
 1020110111
 1020111011
 1020200201
 1020210101
 1020220001
 1020310001
 1021000103
 1021000121
 1021002001
 1021010101
 1021011001
 1021011011
 1021100011
 1021100021
 1021101001
 1021101101
 1021200101
 1021300001
 1022200001
 1023000101
 1030000001
 1030000021
 1030000031
 1030000201
 1030000211
 1030001003
 1030001101
 1030002011
 1030002101
 1030010011
 1030010101
 1030100003
 1030110101
 1030200001
 1031002001
 1031011001
 1031110001
 1032000001
 1040000011
 1040000201
 1040020001
 1040100011
 1040101001
 1041010001
 1050000011
 1100000051
 1100000123
 1100000203
 1100000401
 1100001041
 1100001101
 1100001121
 1100001131
 1100001211
 1100001401
 1100002031
 1100003011
 1100004011
 1100010001
 1100010031
 1100010103
 1100010113
 1100011013
 1100011021
 1100013001
 1100020021
 1100020211
 1100021003
 1100030021
 1100040001
 1100041001
 1100050001
 1100100041
 1100100121
 1100101003
 1100101111
 1100102021
 1100104001
 1100110211
 1100110301
 1100111003
 1100120003
 1100200201
 1100203001
 1100210021
 1100210101
 1100211001
 1100300021
 1100310011
 1100400011
 1100400101
 1101000113
 1101000301
 1101000311
 1101000401
 1101001001
 1101001021
 1101002003
 1101002011
 1101010111
 1101020021
 1101020111
 1101030001
 1101100031
 1101100201
 1101101201
 1101110011
 1101200101
 1101202001
 1101210001
 1102000013
 1102001003
 1102001111
 1102010011
 1102100011
 1102101001
 1102110101
 1102210001
 1103000011
 1103000021
 1103000111
 1103010001
 1103020001
 1103100101
 1103101001
 1104010001
 1104100001
 1110001103
 1110002111
 1110010201
 1110011003
 1110011101
 1110012011
 1110020201
 1110031001
 1110100031
 1110101021
 1110110011
 1110130001
 1110200111
 1110201101
 1110202001
 1110301001
 1111003001
 1111010003
 1111011101
 1111020011
 1111100021
 1111100101
 1111110001
 1111200001
 1112000003
 1112000111
 1112001001
 1112011001
 1113000001
 1113000101
 1120000031
 1120001111
 1120002001
 1120010011
 1120012001
 1120030001
 1120100021
 1120110001
 1120200101
 1120300001
 1121000011
 1121001001
 1121101001
 1122000101
 1130000101
 1130001001
 1130001011
 1130002001
 1130100001
 1130110001
 1131000011
 1140000011
 1140000101
 1140100001
 1200000041
 1200000101
 1200000121
 1200000203
 1200000311
 1200001001
 1200001013
 1200002101
 1200002201
 1200010001
 1200010003
 1200011201
 1200012001
 1200012101
 1200021101
 1200101011
 1200103001
 1200110011
 1200120011
 1200200021
 1200200101
 1200202001
 1200210101
 1200220001
 1200400001
 1201000103
 1201000121
 1201000201
 1201000301
 1201001003
 1201001111
 1201010003
 1201010201
 1201011001
 1201011011
 1201020101
 1201030001
 1201100101
 1201110101
 1202000101
 1202000201
 1202100001
 1203100001
 1204000001
 1210000013
 1210000021
 1210000111
 1210001003
 1210001011
 1210001101
 1210010101
 1210030001
 1210110101
 1211100101
 1212000011
 1212001001
 1221000101
 1230001001
 1300000003
 1300000021
 1300000103
 1300000201
 1300000301
 1300010003
 1300021001
 1300100111
 1300110001
 1300110011
 1300200101
 1300210001
 1301000101
 1301000201
 1301001011
 1301010001
 1301011001
 1301100011
 1302000101
 1302010001
 1303000001
 1310000101
 1310001101
 1310110001
 1320000001
 1400000101
 1400002001
 1400010011
 1400100011
 1400110001
 1401000001
 1401000101
 1500000001
 1500000101
 2000000011
 2000000033
 2000000141
 2000000203
 2000001001
 2000001013
 2000001103
 2000002031
 2000010013
 2000010041
 2000010121
 2000011001
 2000011031
 2000011301
 2000014001
 2000020103
 2000021003
 2000021011
 2000030111
 2000031101
 2000040101
 2000100131
 2000101021
 2000101111
 2000101211
 2000102201
 2000110201
 2000111021
 2000111101
 2000111111
 2000112011
 2000120011
 2000121001
 2000140001
 2000200003
 2000200201
 2000203001
 2000210101
 2000211001
 2000300021
 2000301001
 2000301101
 2000310001
 2000400011
 2000500001
 2001000013
 2001000031
 2001000101
 2001000301
 2001000311
 2001001003
 2001001103
 2001002011
 2001003101
 2001004001
 2001010001
 2001011003
 2001011101
 2001012001
 2001020101
 2001021101
 2001030001
 2001040001
 2001100001
 2001100103
 2001100301
 2001101101
 2001102001
 2001102101
 2001110201
 2001120001
 2001200011
 2001202001
 2001210011
 2001400001
 2002000031
 2002001021
 2002002001
 2002002011
 2002010111
 2002011101
 2002021001
 2002100201
 2002201001
 2003000201
 2003001001
 2003001101
 2003020001
 2004000101
 2004100001
 2010000001
 2010001111
 2010001121
 2010010003
 2010010111
 2010011111
 2010012001
 2010013001
 2010020003
 2010020021
 2010100013
 2010100021
 2010100201
 2010101021
 2010102001
 2010200201
 2010201001
 2010210001
 2010210011
 2010220001
 2010300011
 2010400001
 2011000001
 2011000003
 2011002001
 2011002101
 2011010101
 2011010201
 2011011011
 2011012001
 2011101101
 2011110011
 2011111001
 2012002001
 2012010001
 2012010101
 2012101001
 2020000111
 2020000201
 2020001201
 2020100111
 2020102001
 2021001001
 2021110001
 2030100001
 2030200001
 2031001001
 2040000101
 2100000011
 2100000101
 2100000311
 2100001021
 2100001103
 2100001121
 2100003011
 2100010021
 2100010111
 2100010301
 2100011201
 2100012011
 2100020003
 2100101021
 2100101111
 2100102001
 2100130001
 2100201011
 2100300001
 2100300011
 2101000211
 2101002011
 2101003001
 2101010011
 2101100011
 2101120001
 2101200011
 2102000101
 2102000111
 2102100001
 2103010001
 2110000001
 2110000003
 2110000031
 2110000121
 2110000301
 2110001021
 2110002101
 2110020001
 2110100101
 2110101001
 2110110011
 2111020001
 2111200001
 2120011001
 2120101001
 2130000001
 2130100001
 2200000031
 2200000211
 2200001003
 2200001021
 2200001201
 2200010003
 2200010011
 2200020001
 2200101011
 2200110001
 2200200001
 2201100101
 2202000001
 2202000011
 2210000101
 2212000001
 2300011001
 2300020001
 2300100001
 2301000001
 2301000101
 2301100001
 2400000011
 2401000001
 2500000001
 3000000401
 3000001003
 3000001031
 3000002003
 3000010003
 3000010031
 3000010103
 3000010121
 3000100031
 3000100111
 3000102011
 3000110011
 3000112001
 3000201101
 3000210011
 3000300011
 3001000001
 3001000031
 3001002001
 3001010021
 3001010101
 3001101101
 3001102001
 3002000101
 3002000201
 3002001001
 3003000001
 3010000001
 3010000013
 3010001003
 3010002011
 3010100011
 3010100111
 3010110001
 3010110011
 3010210001
 3011000011
 3011001101
 3011010011
 3011011001
 3011110001
 3012000011
 3012001001
 3020000101
 3020002001
 3020010001
 3020110001
 3021000001
 3030010001
 3100000121
 3100010003
 3100101101
 3100300001
 3101000003
 3101100011
 3102000001
 3102010001
 3110002001
 3110011001
 3110100011
 3110110001
 3130000001
 3200000201
 3200001011
 3300000001
 3300010001
 4000001003
 4000001101
 4000002001
 4000100003
 4000100201
 4000111001
 4000200101
 4000201001
 4001002001
 4001100011
 4002000011
 4002001001
 4002100001
 4010200001
 4020100001
 4030000001
 4100001001
 4100011001
 4101000011
 4101100001
 4110000001
 4110001001
 4111000001
 4200100001
 4210000001
 5000001011
 5000011001
 5002000001
 5010010001
 5020000001
 5100000011
 6000000001
 6000010001
 7000000001
 
 is the sorted output from
 
 DefDbl A-Z
 Dim ns As String, digtot, crlf$
 Function mform$(x, t$)
   a$ = Format$(x, t$)
   If Len(a$) < Len(t$) Then a$ = Space$(Len(t$) - Len(a$)) & a$
   mform$ = a$
 End Function
 
 Private Sub Form_Load()
  Text1.Text = ""
  crlf$ = Chr(13) + Chr(10)
  Form1.Visible = True
 
   For d1 = 1 To 8
    digtot = d1: ns = LTrim(Str(d1))
    addOn 2
   Next
  
 Text1.Text = Text1.Text & crlf & "done" & crlf
 End Sub
 Sub addOn(wh)
   For newdig = 0 To 7
     c$ = LTrim(Str(newdig))
     digtot = digtot + newdig
     ns = ns + c
     If digtot <= 9 Then
      If digtot < Len(ns) Then
        v = Val(ns)
        If prmdiv(v) = v Then
          Text1.Text = Text1.Text & mform(v, "###########") & crlf
          DoEvents
        End If
      End If
      If wh < 10 Then addOn wh + 1
     End If
     ns = Left(ns, wh - 1)
     digtot = digtot - newdig
   Next
 End Sub
 
 
 Function prmdiv(num)
  Dim n, dv, q
  If num = 1 Then prmdiv = 1: Exit Function
  n = Abs(num): If n > 0 Then limit = Sqr(n) Else limit = 0
  If limit <> Int(limit) Then limit = Int(limit + 1)
  dv = 2: GoSub DivideIt
  dv = 3: GoSub DivideIt
  dv = 5: GoSub DivideIt
  dv = 7
  Do Until dv > limit
    GoSub DivideIt: dv = dv + 4 '11
    GoSub DivideIt: dv = dv + 2 '13
    GoSub DivideIt: dv = dv + 4 '17
    GoSub DivideIt: dv = dv + 2 '19
    GoSub DivideIt: dv = dv + 4 '23
    GoSub DivideIt: dv = dv + 6 '29
    GoSub DivideIt: dv = dv + 2 '31
    GoSub DivideIt: dv = dv + 6 '37
  Loop
  If n > 1 Then prmdiv = n
  Exit Function
 
 DivideIt:
  Do
   q = Int(n / dv)
   If q * dv = n And n > 0 Then
     prmdiv = dv: Exit Function
    Else
     Exit Do
   End If
  Loop
 
  Return
 End Function

which produces numbers in lexicographic order (1112000111 comes before 20101 as 1 is less than 2).


  Posted by Charlie on 2015-05-04 19:22:39
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 (20)
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