/* prime.tc - 2/19/2011 - tct */ prime int p [return(factor(p)==p)] is int i;char s(0) [ if !i strcpy(s," is composite") else strcpy(s," is prime") ] test [ char s(20);int pc ps "enter number : ";pc=gn;is(prime(pc),s);pl "";MC(pc,14);ps s pl "" ] main int pc [ ps "prime.tc - 2/19/2011 - tct";pl "" int w while ((w=factor(pc))!=pc) [ MC(w,14);ps "*";pc=pc/w ] MC(w,14) ] factor int f [ /* returns smallest factor of f int p(42),j p(0)=2;p(1)=3;p(2)=5;p(3)=7;p(4)=11;p(5)=13 p(6)=17;p(7)=19;p(8)=23;p(9)=29;p(10)=31 p(11)=37;p(12)=41;p(13)=43;p(14)=47;p(15)=53 p(16)=59;p(17)=61;p(18)=67;p(19)=71 p(20)=73;p(21)=79;p(22)=83;p(23)=89 p(24)=97;p(25)=101;p(26)=103;p(27)=107 p(28)=109;p(29)=113;p(30)=127;p(31)=131 p(32)=137;p(33)=139;p(34)=149;p(35)=151 p(36)=157;p(37)=163;p(38)=167;p(39)=173 p(40)=179;p(41)=181;p(42)=191 while p(j)*p(j)<=f [ if (f/p(j)*p(j)==f) return p(j) ++j ] return f ]