// Arithmetic Derivative // https://rosettacode.org/wiki/Arithmetic_derivative# local fn DoIt( N as short) as short short L,F,Z L = 0: F = 3: Z = ABS(N) IF Z<2 THEN exit fn 1 IF Z MOD 2 = 0 THEN L=L+N\2: Z=Z\2: GOTO 1 2 IF F>Z THEN exit fn 3 IF Z MOD F = 0 THEN L=L+N\F: Z=Z\F: GOTO 2 F=F+2 goto 1 end fn = L _Window = 1 window _Window,@"Arithmetic Derivative",fn cgrectmake(0,0,640,400) windowcenter(_Window) short N,L,LineCount FOR N = -99 TO 100 L = fn DoIt(N): PRINT USING "########";L; LineCount ++ if LineCount = 10 then print : LineCount = 0 NEXT handleevents