Warning: Function ereg() is deprecated in ..../includes/class_postbit.php(345) : eval()'d code on line 4

Warning: Function split() is deprecated in ..../includes/class_postbit.php(345) : eval()'d code on line 19

Warning: Function ereg() is deprecated in ..../includes/class_postbit.php(345) : eval()'d code on line 4

Warning: Function split() is deprecated in ..../includes/class_postbit.php(345) : eval()'d code on line 19
Programming challenges - Page 3
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. Need Help with Network Programming
    By omidkamangar in forum Programming
    Replies: 1
    Last Post: 05-01-2006, 03:23 PM
  2. Microsoft Search Engine Challenges Google
    By genesis in forum Windows - General Topics
    Replies: 10
    Last Post: 02-04-2005, 09:21 PM
  3. Programming
    By imported_n00b in forum Announcements and Suggestions
    Replies: 12
    Last Post: 09-17-2004, 06:35 PM
  4. Programming
    By Asbenson in forum General Chat
    Replies: 34
    Last Post: 06-19-2004, 04:54 AM
  5. Programming Challenges
    By ndogg in forum Programming
    Replies: 1
    Last Post: 12-12-2001, 12:27 PM

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
  •