Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Challenges
#32
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
Reply


Messages In This Thread
Challenges - by bplus - 04-27-2022, 05:21 PM
RE: Challenges - by Pete - 04-27-2022, 05:33 PM
RE: Challenges - by bplus - 04-27-2022, 05:38 PM
RE: Challenges - by Pete - 04-27-2022, 06:00 PM
RE: Challenges - by bplus - 04-27-2022, 06:08 PM
RE: Challenges - by bplus - 04-28-2022, 01:17 AM
RE: Challenges - by Dav - 04-28-2022, 01:26 AM
RE: Challenges - by Pete - 04-28-2022, 01:59 AM
RE: Challenges - by bplus - 05-04-2022, 01:36 AM
RE: Challenges - by Pete - 05-04-2022, 01:51 AM
RE: Challenges - by bplus - 05-04-2022, 01:57 AM
RE: Challenges - by Pete - 05-04-2022, 02:22 AM
RE: Challenges - by bplus - 05-04-2022, 04:10 PM
RE: Challenges - by bplus - 06-18-2022, 01:10 PM
RE: Challenges - by SierraKen - 06-18-2022, 11:32 PM
RE: Challenges - by bplus - 06-19-2022, 01:09 AM
RE: Challenges - by bplus - 03-26-2024, 11:37 PM
RE: Challenges - by CharlieJV - 03-30-2024, 12:02 AM
RE: Challenges - by SMcNeill - 03-27-2024, 12:20 AM
RE: Challenges - by SMcNeill - 03-27-2024, 12:32 AM
RE: Challenges - by bplus - 03-27-2024, 01:24 AM
RE: Challenges - by bplus - 03-30-2024, 02:53 PM
RE: Challenges - by CharlieJV - 03-30-2024, 03:39 PM
RE: Challenges - by bplus - 03-31-2024, 01:33 PM
RE: Challenges - by Petr - 03-31-2024, 02:00 PM
RE: Challenges - by SMcNeill - 03-31-2024, 02:18 PM
RE: Challenges - by Petr - 03-31-2024, 02:23 PM
RE: Challenges - by bplus - 03-31-2024, 03:28 PM
RE: Challenges - by bplus - 06-18-2024, 10:42 PM
RE: Challenges - by SMcNeill - 06-19-2024, 04:32 AM
RE: Challenges - by SMcNeill - 06-19-2024, 04:45 AM
RE: Challenges - by KingLeonidas - 06-19-2024, 09:42 AM
RE: Challenges - by bplus - 06-19-2024, 01:59 PM
RE: Challenges - by bplus - 06-21-2024, 07:31 PM
RE: Challenges - by bplus - 06-23-2024, 03:07 PM



Users browsing this thread: 12 Guest(s)