How to list all the prime factor?
November 2nd, 2006 mysurface Posted in Calculation, cut, factor | Hits: 46010 | 1 Comment »
Are you thinking of using c/c++ or bash script to do that? Don’t do that, linux have ready made command. Its call factor.
Let say I want to list the prime factor for 232.
factor 232
The result will be
232: 2 2 2 29
What if I want only the factor with the “232:” ? We can use cut with -complement.
factor 232 | cut -f1 -d" " --complement
By specifying -f1 -d” “, it suppose to extract column 1, but because I ask it for complement, I get this:
2 2 2 29







June 26th, 2011 at 1:37 am
Check bellow link for finding prime factors of a given number bash script
http://bashscript.blogspot.com/2011/06/shell-script-to-find-prime-factors-of.html