Tom's Guide | Tom's Hardware | Tom's Games
![]() |
![]() |
![]() |
Am i missing something here:
#include "primes.h" /*how to linkto main.c*/
int is_prime(int n)
{
int k;
int limit;if (n == 2)
return 1;
if (n % 2 == 0)
return 0;
limit = n / 2;
for (k = 3; k <= limit; k += 2)
if (n % k == 0)
return 0;
return 1;
}
I do not think that this works. What I am trying tho do is prime number search up to a specific number input from keyboard. I have xphe, P4 3.0 512KMB, nvidia 6800. Using micro$oft visual 2005.The first row is the amount of primes you want to see: printf("%5d: ", i);
How do I link is_prime() to main to display all prime numbers after the ":"
I have looked at C++ programming website and was unable to locate answer. I have found prime number algorithm but it didn't work on my machine. "By the way I'm a newbe @ programming. Any help would greatly be appreciated
Hmmmmmmmm........

![]() |
![]() |
![]() |

This post is quite old and has been locked from receiving new replies. Please create a new posting instead.
| Ads by Google |