Print Prime Numbers
Print prime numbers from 1 to 500. We know about prime number a number which is divisible by itself is called prime.
#!/usr/bin/env python for num in range(2,501): flag = 0 for i in range(2,int(num**0.5)) : if (num % i) == 0: flag+=1 break if flag == 0 : print num
For more programs on Python, visit our Python Coder Archives
All rights reserved. No part of this Post may be copied, distributed, or transmitted in any form or by any means, without the prior written permission of the website admin, except in the case of brief quotations embodied in critical reviews and certain other noncommercial uses permitted by copyright law. For permission requests, write to the owner, addressed “Attention: Permissions Coordinator,” to the admin @coderinme