You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
hi
the first example I tried never print out anything. maybe movcc does not work with argc,argv,atoi etc, so I got rid of them all, and set the number of primes to a constant 10, and use only one external function "printf". still, it never print out anything. maybe you should give it a try. what is the speed normally like?
main()
{
int n, i = 3, count, c;
//n=10000;
//printf("Enter the number of prime numbers required\n");
//scanf("%d",&n);
n=10;
if ( n >= 1 )
{
// printf("First %d prime numbers are :\n",n);
printf("2\n");
}
for ( count = 2 ; count <= n ; )
{
for ( c = 2 ; c <= i - 1 ; c++ )
{
if ( i%c == 0 )
break;
}
if ( c == i )
{
printf("%d\n",i);
count++;
}
i++;
}
}
// original version
#include <stdio.h>
int main(int argc,char** argv)
{
int n, i = 3, count, c;
//n=10000;
//printf("Enter the number of prime numbers required\n");
//scanf("%d",&n);
if (argc<2) {printf("%s number.of.primes\n",argv[0]);return 1;}
n=atoi(argv[1]);
if ( n >= 1 )
{
// printf("First %d prime numbers are :\n",n);
printf("2\n");
}
for ( count = 2 ; count <= n ; )
{
for ( c = 2 ; c <= i - 1 ; c++ )
{
if ( i%c == 0 )
break;
}
if ( c == i )
{
printf("%d\n",i);
count++;
}
i++;
}
return 0;
}
The text was updated successfully, but these errors were encountered:
hi
the first example I tried never print out anything. maybe movcc does not work with argc,argv,atoi etc, so I got rid of them all, and set the number of primes to a constant 10, and use only one external function "printf". still, it never print out anything. maybe you should give it a try. what is the speed normally like?
main()
{
int n, i = 3, count, c;
//n=10000;
//printf("Enter the number of prime numbers required\n");
//scanf("%d",&n);
n=10;
if ( n >= 1 )
{
// printf("First %d prime numbers are :\n",n);
printf("2\n");
}
for ( count = 2 ; count <= n ; )
{
for ( c = 2 ; c <= i - 1 ; c++ )
{
if ( i%c == 0 )
break;
}
if ( c == i )
{
printf("%d\n",i);
count++;
}
i++;
}
}
// original version
#include <stdio.h>
int main(int argc,char** argv)
{
int n, i = 3, count, c;
//n=10000;
//printf("Enter the number of prime numbers required\n");
//scanf("%d",&n);
if (argc<2) {printf("%s number.of.primes\n",argv[0]);return 1;}
n=atoi(argv[1]);
if ( n >= 1 )
{
// printf("First %d prime numbers are :\n",n);
printf("2\n");
}
for ( count = 2 ; count <= n ; )
{
for ( c = 2 ; c <= i - 1 ; c++ )
{
if ( i%c == 0 )
break;
}
if ( c == i )
{
printf("%d\n",i);
count++;
}
i++;
}
return 0;
}
The text was updated successfully, but these errors were encountered: