PHP stuff
<?
$y=1;
$x=1;
if(!$max)
{$max=200;}
while($x++<$max)
{
while($y++<$max)
{
if($q[$y]==0){$q[$x*$y]=1;}
}
$y=1;
}
for($x=0;$x<($max*2);$x++)
{if($q[$x]==0){echo "$x
";}}
?>
C++ interpretation doesn't work
#include <iostream>
using namespace std;
int main()
{
int max;
cout<<"need max\n";
cin>>max;
long y=2;
long x=2;
bool q[max];
for(x=0;x<max;x++){q[x]=0;}
x=2;
while(x++<max)
{
while(y++<max)
{
if(q[y]==0){q[x*y]=1;}
}
y=2;
}
for(x=0;x<(max*2);x++)
{
if(q[x]==0){cout <<x<<'\n';}}
}
It prints:
0
1
then exits
It's supposed to display prime numbers.
I removed the if from the for loop and changed (max*2) to max, still kills the app.
<?
$y=1;
$x=1;
if(!$max)
{$max=200;}
while($x++<$max)
{
while($y++<$max)
{
if($q[$y]==0){$q[$x*$y]=1;}
}
$y=1;
}
for($x=0;$x<($max*2);$x++)
{if($q[$x]==0){echo "$x
";}}
?>
C++ interpretation doesn't work
#include <iostream>
using namespace std;
int main()
{
int max;
cout<<"need max\n";
cin>>max;
long y=2;
long x=2;
bool q[max];
for(x=0;x<max;x++){q[x]=0;}
x=2;
while(x++<max)
{
while(y++<max)
{
if(q[y]==0){q[x*y]=1;}
}
y=2;
}
for(x=0;x<(max*2);x++)
{
if(q[x]==0){cout <<x<<'\n';}}
}
It prints:
0
1
then exits
It's supposed to display prime numbers.
I removed the if from the for loop and changed (max*2) to max, still kills the app.