Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Prime factors in 25 lines or less
#9
That wasn't very nice.

Did I call you an arrogant noob?

No...

Anyway, I posted mine in the FAQ, so I guess I'll post it again since neuro volunteered his code..

Code:
CLS
DIM testfactor&(1 TO 100)
DIM isfactored%(1 TO 100)
n% = 1
newfree% = 1
INPUT "What is the number you want to factor"; testfactor&(n%)
DO
if testfactor%(n%) = 0 THEN EXIT DO

FOR testdiv& = 2 TO testfactor%(n%) ^ .5
'There is a more efficient way to do \ and /, but I don't remember it.
result1& = testfactor&(n%) \ testdiv&
IF result1& = testfactor&(n%) / testdiv& THEN
isfactored%(n%) = 1
testfactor&(newfree% + 1) = result1&
testfactor&(newfree% + 2) = testdiv&
newfree% = newfree% + 2
EXIT FOR
END IF
NEXT testdiv&
n% = n% + 1
LOOP

FOR i% = 1 TO newfree%
IF isfactored%(i%) = 0 THEN PRINT testfactor&(i%)
next i%
SLEEP
Peace cannot be obtained without war. Why? If there is already peace, it is unnecessary for war. If there is no peace, there is already war."

Visit www.neobasic.net to see rubbish in all its finest.
Reply


Messages In This Thread
Prime factors in 25 lines or less - by whodat - 10-07-2005, 10:21 PM
Prime factors in 25 lines or less - by Agamemnus - 10-08-2005, 07:05 AM
from an ageing newbie - by whodat - 10-09-2005, 02:41 AM
Prime factors in 25 lines or less - by Agamemnus - 10-09-2005, 02:49 AM
Prime factors in 25 lines or less - by whodat - 10-09-2005, 03:08 AM
Prime factors in 25 lines or less - by neuro - 10-09-2005, 03:35 AM
Prime factors in 25 lines or less - by speedlemon - 10-09-2005, 03:51 AM
Prime factors in 25 lines or less - by Agamemnus - 10-09-2005, 04:11 AM
Prime factors in 25 lines or less - by whodat - 10-09-2005, 05:41 AM
I like it - by whodat - 10-09-2005, 05:57 AM
Am I doing something wrong? - by whodat - 10-09-2005, 06:06 AM
Prime factors in 25 lines or less - by rpgfan3233 - 10-09-2005, 10:27 AM
Prime factors in 25 lines or less - by d.j.peters - 10-09-2005, 11:17 PM
Prime factors in 25 lines or less - by Agamemnus - 10-10-2005, 01:43 AM
Prime factors in 25 lines or less - by whodat - 10-10-2005, 02:01 AM
Prime factors in 25 lines or less - by Agamemnus - 10-10-2005, 02:13 AM
Prime factors in 25 lines or less - by whodat - 10-10-2005, 02:58 AM
Prime factors in 25 lines or less - by whodat - 10-10-2005, 03:04 AM
Prime factors in 25 lines or less - by Quibbler - 10-10-2005, 06:05 PM
Prime factors in 25 lines or less - by rpgfan3233 - 10-10-2005, 09:24 PM
Prime factors in 25 lines or less - by Quibbler - 10-10-2005, 09:37 PM
Prime factors in 25 lines or less - by Quibbler - 10-11-2005, 01:07 AM

Forum Jump:


Users browsing this thread: 2 Guest(s)