Page 3 of 3 FirstFirst 123
Results 21 to 22 of 22

Thread: Programming challenges

  1. #21

    Re: Programming challenges

    postfix is done, and I've just got a bit of array juggling to do for 2. These high school probs are just about the right level for me. Who knows one day I may even be l33t. ;D

  2. #22
    Guest

    Re: Programming challenges

    2001, factorial.

    Code:
    #!/usr/bin/env python
    
    import sys
    
    def fact(n):
     total = 1
     for i in xrange(1, n+1):
      total *= i
    
     return total
    
    
    if __name__ == '__main__':
     if len(sys.argv) < 2:
      print "Usage: %s <Integer>" % sys.argv[0]
      sys.exit(1)
    
     try:
      target = abs(int(sys.argv[1]))
     except:
      print "Illegal number"
      sys.exit(1)
     
    
     print fact(target)

Similar Threads

  1. Programming language development
    By tech291083 in forum Programming
    Replies: 1
    Last Post: 10-15-2007, 02:39 PM
  2. Not sure my college is good for Programming
    By mariline in forum Windows - General Topics
    Replies: 0
    Last Post: 08-16-2007, 09:16 PM
  3. Difference in programming??
    By in forum Programming
    Replies: 11
    Last Post: 07-04-2003, 08:03 PM
  4. Unix Network Programming Review
    By Aaron_Adams in forum Programming
    Replies: 8
    Last Post: 03-17-2002, 11:25 AM
  5. Programming Challenges
    By ndogg in forum Programming
    Replies: 1
    Last Post: 12-12-2001, 11:27 AM

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •