Skip to content

Instantly share code, notes, and snippets.

@Sangram92
Created February 25, 2016 09:55
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Sangram92/1cd58a18a5970373c87b to your computer and use it in GitHub Desktop.
Save Sangram92/1cd58a18a5970373c87b to your computer and use it in GitHub Desktop.
"""find the all the possible prime number from the given integer number
input : 3657
output : 3 5 7 37 53 67 73 367 563 653 673
"""
import itertools
final_list = []
num = raw_input("Enter no : ")
for x in range(1,len(num)+1):
sep_list = [int(''.join(a)) for a in list(itertools.permutations(num, x))]
final_list.extend(sep_list)
print "Generated Possible Permutation No List", "\n", final_list
def prime(list):
prime_no = []
for num in list:
if num > 1:
for i in range(2,num):
if (num % i) == 0:
break
else:
prime_no.append(num)
print "Prime No List : ", prime_no
prime(final_list)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment