A BASIC Program To Factor Numbers Into Primes

A BASIC Program To Factor Numbers Into Primes

This program is written in Just BASIC v1.01, which you may download for free at http://justbasic.com/download.html.

*** *** ***

10 print “For what number do you want the prime factorization”;
20 input n
25 c = 3
30 if n <> int(n) then end
40 if n < 4 then goto 450
50 if n/2 <> int(n/2) then goto 100
60 print ” 2″;
70 n = n/2
75 if n = 1 then goto 400
80 goto 50
100 if n/3 <> int(n/3) then goto 200
110 print ” 3″;
120 n = n/3
125 if n = 1 then goto 400
130 goto 100
200 c = c + 2
205 p = 0
210 for t = 3 to c step 2
220 if c/t = int(c/t) then goto 290
230 if n/t <> int(n/t) then goto 290
240 if p > 0 then goto 290
250 p = t
290 next t
295 if p = 0 then goto 200
300 print ” “;p;
310 n = n/p
320 if n = 1 then goto 400
330 if n/p = int(n/p) then goto 300
340 goto 200
400 print
410 goto 10
450 if n = 2 then print ” 2″;
460 if n = 3 then print ” 3″;
470 goto 400
500 end

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s