I am trying to run something of the form
p = Permutations[Range[1,16]];
result={};
Table[If["p[[i]] satisfies some conditions",result=Append[result,p[[i]]]],{i,1,Length[[p]]}];
and I get an "out of memory error" when defining p. I am trying to find a way around this, especially since I don't really need to store Permutations[Range[1,16]] at any given point. All I want is access the i-th element of it and run some tests (for all i). I understand this might take ages but I can afford to let the program run for months, whereas the memory of the computer I am using is restricted. Any ideas?
A "proper" minimal example:
p = Permutations[Range[1,16]];
result={};
Table[If[p[[i]]==Range[1,16],result=Append[result,p[[i]]]],{i,1,Length[p]}];
result
and the expected output would be {1,2,3,4,..,16}.