home *** CD-ROM | disk | FTP | other *** search
/ Mac Easy 2010 May / Mac Life Ubuntu.iso / casper / filesystem.squashfs / usr / share / doc / dc / examples / dc_factor
Encoding:
Text File  |  2007-12-05  |  446 b   |  18 lines

  1. #!/bin/sh
  2. #
  3. # Example taken from http://www.cs.unh.edu/~charpov/Programming/DC/
  4. # and minimally modified to use dc -e '...' instead of echo '...' | dc
  5. #
  6. # Usage:
  7. #    Invoke as 'dc_factor $ARG' and $ARG will be factored
  8. # Example:
  9. #     $ ./dc_factor 123456789              
  10. #     3
  11. #     3
  12. #     3607
  13. #     3803
  14. #
  15. # Dirk Eddelbuettel <edd@debian.org>  09 May 2003
  16.  
  17. dc -e "$1[p]s2[lip/dli%0=1dvsr]s12sid2%0=13sidvsr[dli%0=1lrli2+dsi!>.]ds.xd1<2"
  18.