06-19-2024, 09:42 AM
(This post was last modified: 06-19-2024, 09:43 AM by KingLeonidas.)
Bonus points if you can calculate the O(n) eval time of SMcNeill's brutal algorithm.
Code: (Select All)
FOR n = 1 TO 945 '1000
FOR j = 2 TO INT(n / 2)
q = n / j
p = INT(j / 2)
t = 0
trigger = 0
IF (q > p) THEN
IF ((j MOD 2) <> 0) THEN ' j Odd
f = 0
IF (q = INT(q)) THEN
trigger = 1
END IF
ELSE ' j Even
f = .5
IF ((n MOD 2) = 0) THEN ' n Even
IF (q - p) <> INT(q - p) THEN
IF (q * 2 = INT(q * 2)) THEN
trigger = 1
END IF
END IF
ELSE ' n Odd
IF (q * 2 = INT(q * 2)) THEN
trigger = 1
END IF
END IF
END IF
IF (trigger = 1) THEN
PRINT j; ")"; q * j; "=";
FOR k = q - p + f TO q + p - f
PRINT k;
t = t + k
NEXT
PRINT "="; t
END IF
END IF
NEXT
NEXT