Python_ Printing without looping 1-1000

Source: Internet
Author: User

Title: Print 1-1000 of these 1000 numbers on the screen, do not use circular statements/conditional statements, do not use?: operator. Not allowed in the source code to enumerate the output statement method silly dozen, such as 1000 print statements do not, no longer repeat other silly dozen behavior, we can understand the spirit. Answer:
Import Syssys.setrecursionlimit (1005) def PR (n):   Print ' %d ' % n  #  t = Int (1/(n-1000))  if n <:    PR (n+1)    #  return None  #  return NonePR (1)
On the Internet, we found that Python's default recursion depth is very limited, probably more than 900, and when the recursion depth exceeds this value, an exception is thrown. The solution is to manually set the recursive call depth in the following way:
Import sys   Sys.setrecursionlimit (# For example here set to 1 million

Python_ Printing without looping 1-1000

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.