Oops, now that was really dumn - I forgot to attach the algorithm. Wel, here it is:...... primefind factorchecker=0 primefindloop if(factorchecker < number) isafactor() isafactor? number++ goto primefind else factorchecker++ goto primecheckloop (if here, no factors) print number number++ goto primefind isafactor (factorchecker & number) x=number y=2 while ( (x-factorchecker) >= 0 ) x=x-factorchecker y++ if(x=0) retlw 1 else retlw 0 On 5/14/05, Dave Turner wrote: > Hi. I just finished coming up with this algorithm to find prime > numbers. In this, number is the number to be checked if it's a prime. > factor checker is the number to be checked if it is a factor of > number. in isafactor, x is the current working number, y is the > result of the integer division (isafactor is a sort of > modulus/divide). I'm just wondering if this is more or less right, to > be coded in ASM. It really doesn't need to be optimised at all. > Also, does anyone know how to alter this / code with larger numbers > than 255 (1 byte)? Do I have to write my own routines to work with > words? BTW, I am coding for the PIC18F1320. > -- http://www.piclist.com PIC/SX FAQ & list archive View/change your membership options at http://mailman.mit.edu/mailman/listinfo/piclist