تجزیه به عوامل اول
این برنامه عدد ورودی را به عوامل اول تجزیه می کند
CLS lz = 1 DIM az(10000), avals(10000) kz = 100000 gz = INT(SQR(kz)) avals(lz) = 2 FOR iz = 3 TO gz STEP 2 cz = 0 FOR jz = 2 TO iz \ 2 rz = iz MOD jz IF rz = 0 THEN cz = cz + 1: EXIT FOR NEXT jz IF cz = 0 THEN lz = lz + 1 avals(lz) = iz nz = nz + 1 az(nz) = iz END IF NEXT iz IF gz MOD 2 = 0 THEN gz = gz + 1 FOR iz = gz TO kz STEP 2 cz = 0 FOR jz = 1 TO nz rz = iz MOD az(jz) IF rz = 0 THEN cz = cz + 1: EXIT FOR NEXT jz IF cz = 0 THEN lz = lz + 1 avals(lz) = iz mz = mz + 1 END IF NEXT iz '**************************************** DEF fnmm (n) DIM b(1000), c(1000) i = 0: k = 0: m = 0: j = 0: aval = 2 WHILE n <> 1 m = n MOD aval IF m = 0 THEN n = n / aval IF aval = laval THEN j = j + 1 c(k) = j ELSE j = 1 k = k + 1 b(k) = aval c(k) = j laval = aval END IF ELSE i = i + 1 aval = avals(i) END IF WEND q = 1 FOR p = 1 TO k PRINT b(p); "^"; c(p); "*"; t = ((b(p) ^ (c(p) + 1)) - 1) / (b(p) - 1) q = q * t NEXT p PRINT fnmm = q END DEF print "Down load in WWW.SYS.blogsky.com" '**************************************** input v tgzeh=fnmm(v)
SALAM, CHE KHABAR BE MA KE SAR NEMIZANI TA ROH MAHET RO BEBINAM MAJBURAM KHODAM BIAM PISHET
SALAM, CHE KHABAR BE MA KE SAR NEMIZANI TA ROH MAHET RO BEBINAM MAJBURAM KHODAM BIAM PISHET