-1

the assignment is 'We provide you with a value N. Calculate N! and output only the final result.' Can not figure this out for the life of me and I do not understand why my code will not run in the least.

 # Get N from the command line
      import sys
      N = int(sys.argv[1])

      def factorial(N):
      num = 1
      while N >= 1:
      num = num * N
      N = N - 1
      print(N)

1 Answers1

0

First, fix the formatting of your code.. It doesn't look right..

Your code is working fine. But you are printing the wrong number as answer. The factorial is stored in num. So try printing num instead of N

Sunitha
  • 11,777
  • 2
  • 20
  • 23