This can be expanded into a prime sieve that shows what he has here.
#prime.pl
use Math::Complex;
use Math::Trig;
use POSIX;
# P = A = 1/2 B (6 n-cos(pi n)+3) \ B = 1/2 (6 n-cos(pi n)+3)
my $pi = pi;
my @k;
my $count = "100";
my $n = "1";
my @c;
### given two sets A, B returns B \ A (ie all elements that are in B but NOT in A)
sub complement
{
my @set1 = @c;
my @set2 = @k;
my @ans=();
## find intersection of A and B
my @intersection=(@set1);
for(my $i=0;$i<@set2;$i++)
{
for(my $j=0;$j<@intersection;$j++)
{
if($set2[$i] eq $intersection[$j])
{
$set2[$i]="?";
}
}
}
for(my $i=0;$i<@set2;$i++)
{
push(@ans,$set2[$i]) if $set2[$i]!~m/\?/;
}
return @ans;
}
for ($count = 100000 ;$count >= $n; $n++){
my $k = ((3 * $n) - (0.5 * cos($pi*$n))) + 1.5;
push (@k, $k);
}
my $c;
my $x = $#k;
my $y = $k[$x];
foreach (@k){
my $b = $_;
my $n = "1";
$c=1;
next if ($b >= floor(sqrt($y + 1)));
for ($count = $y + 1 ;$count >= $c; $n++){
$c = (((3 * $n) - (0.5 * cos($pi*$n))) + 1.5) * $b;
next unless ($c <= $y + 1);
push (@c, $c);
}
}
print "stophere";
%hashTemp = map { $_ => 1 } @c;
@c = keys %hashTemp;
@c = sort { $a <=> $b } @c;
#@P = ∁
print "stophere";
foreach (@k){
my $b = $_;
my $n = "1";
$c=1;
next if ($b >= floor(sqrt($y + 1)));
for ($count = $y + 1 ;$count >= $c; $n++){
$c = (((3 * $n) - (0.5 * cos($pi*$n))) + 1.5) * $b;
next unless ($c <= $y + 1);
push (@c, $c);
}
}
Allows you to iterate of the next set and find the none prime and remove them from the SET of 1/2 (6 n-cos(pi n)+3) Thats how a sieve works. 1/2 (6 n-cos(pi n)+3) is only good up to n^2 then you need to multiply 1/2 (6 n-cos(pi n)+3) by i as you noted the first non-prime result was @ 5^2 therefore you need to sieve the rest of the numbers up to 7^2 by doing (1/2 (6 n-cos(pi n)+3)) * 5 Then after 7^2 seive off with (1/2 (6 n-cos(pi n)+3)) * 7 you continue to repeat this for all numbers in the original set. See the sieve of eratosthenes. Mine though shows primes as a set of sin waves kind of like what the op has. As a matter of fact the post is basically a visual representation of what I coded above.
This can be expanded into a prime sieve that shows what he has here.