Program to store 1000 prime numbers in an array and print out every 15th
This is a program to put the first 1000 numbers in an array and print out every 15th. It compiles but the program crashes.
Code:
#include <stdio.h>
int main ()
{
int array[1000];
int a=0;
int num1=2;
int num2=0;
int b = 0;
printf("These are every 15th prime number up to the 1000th prime:\n\n");
while (b < 1000){
while ( num1 < b ){
if ( b%num2 == 0){
num2++;
}
num1++;
}
if (num2 == 0){
array[b] = b;
}
b++;
}
b=0;
while (b<=1000){
printf("%d\n",array[b]);
b+15;
}
return 0;
}