(In reply to
7-up by Dej Mar)
I'd be curious as to the method of finding those large Smith numbers. The program below only ventured to check up to 1 million, and as a result found no groups larger than 3:
DECLARE FUNCTION sodFact# (num#)
DECLARE FUNCTION sod# (x#)
DEFDBL A-Z
DIM SHARED prime
CLS
FOR i = 1 TO 1000000
IF sod(i) = sodFact(i) THEN
IF prime = 0 THEN
IF i <> prev + 1 THEN
IF smCt > 2 THEN
FOR j = 1 TO smCt
PRINT h(j);
NEXT
PRINT
END IF
smCt = 1
h(smCt) = i
prev = i
ELSE
smCt = smCt + 1
h(smCt) = i
prev = i
END IF
END IF
END IF
NEXT
FUNCTION sod (x)
n$ = LTRIM$(STR$(x))
t = 0
FOR i = 1 TO LEN(n$)
t = t + VAL(MID$(n$, i, 1))
NEXT
sod = t
END FUNCTION
FUNCTION sodFact (num)
totl = 0
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
IF INKEY$ = CHR$(27) THEN EXIT FUNCTION
LOOP
IF n > 1 THEN totl = totl + sod(n): pct = pct + 1
IF pct = 1 THEN prime = 1: ELSE prime = 0
sodFact = totl
EXIT FUNCTION
DivideIt:
rep = 0
DO
q = INT(n / dv)
IF q * dv = n AND n > 0 THEN
totl = totl + sod(dv): pct = pct + 1
n = q
IF n > 0 THEN limit = SQR(n): ELSE limit = 0
IF limit <> INT(limit) THEN limit = INT(limit + 1)
ELSE
EXIT DO
END IF
LOOP
RETURN
END FUNCTION
designed to find triples and above, finds only
73615 73616 73617
209065 209066 209067
225951 225952 225953
283745 283746 283747
305455 305456 305457
342879 342880 342881
656743 656744 656745
683670 683671 683672
729066 729067 729068
747948 747949 747950
774858 774859 774860
879221 879222 879223
954590 954591 954592
so no quadruplets or higher occur starting below one million.
|
Posted by Charlie
on 2010-08-22 01:32:43 |