Skip to content

Instantly share code, notes, and snippets.

@abdulmuneer
Created October 12, 2011 08:30
Show Gist options
  • Save abdulmuneer/1280650 to your computer and use it in GitHub Desktop.
Save abdulmuneer/1280650 to your computer and use it in GitHub Desktop.
Printing n numbers without using condition/loop/range
#Printing n numbers without using condition/loop/range
#dangerous to use :) Involves modifying sys variables that can crash \
#other python programs sharing the same interpreter
import sys
def strange_print(n):
print n
n+=1
try:
strange_print(n)
except:
print n
return
def main():
try:
n = int(raw_input('Plz enter the number\n'))
except:
print 'Enter an integer\n'
main()
sys.setrecursionlimit(n)
strange_print(1)
if __name__ == '__main__':
main()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment