#include <stdio.h>
#include <stdlib.h>
#include <math.h>
#include <ctype.h>
#define MAXVALUE 1000000
int main(int argc, char *argv[]){
if (argc != 3){
printf("Warning: Check number of arguments.\n";
return 1;
}
int i, j;
for (j = 1; j <= 2; j++){
for (i = 0; argv[j] != '\0'; i++){
if (!isdigit(argv[j])) {
printf("Warning: Please enter a valid integer.\n";
return 1;
}
}
}
char *endptr;
int n = strtol(argv[2], &endptr, 10), k = strtol(argv[1], &endptr, 10); //convert argv to int
if (n > MAXVALUE || k == 1 || k >= n){
printf("Warning: Bad input.\n";
return 1;
}
getPrimes(n, k);
return 0;
}
int i, j, primeArray[n];
for (i = n; i--; )
primeArray = 1;
for (i = 2; i * i < n; i++)
for (j = i * i; j < n; j += i)
primeArray[j] = 0;
for (k = k; k < n; k++)
if (primeArray[k] == 1)
printf("%d\n", k);
Last reply 2 minutes ago
Civil service - location allocations and preference DWPLast reply 6 minutes ago
International graduate student looking for graduate scheme that sponsors visa.Last reply 6 minutes ago
Official University of St Andrews Applicant Thread for 2024Last reply 8 minutes ago
Can someone please mark this out of 30(all my teachers refused)Last reply 9 minutes ago
LSE Undergraduate Politics and IR 2024Last reply 10 minutes ago
Will an IVA cause my Civil Service pre employment check to fail?Last reply 11 minutes ago
Inlaks, Commonwealth, and Other Scholarships for Indian Students 2024: ThreadLast reply 11 minutes ago
Haven't heard back from LSELast reply 12 minutes ago
Accenture Degree Apprenticeship 2024Posted 12 minutes ago
How to choose unis in UCAS application for CS undergraduate course?Last reply 13 minutes ago
Official University of Bath Offer Holders Thread for 2024 entryLast reply 14 minutes ago
Medical doctor degree apprenticeship 2024Last reply 16 minutes ago
Social Security Scotland - Client ManagerLast reply 17 minutes ago
SIP civil service 2024 threadLast reply 18 minutes ago
NICS Staff Officer and Deputy Principal recruitment 2022 2023Last reply 1 month ago
Free website hosting providers with no strings attached?Posted 3 months ago
iDEA silver citizen badge three. Milkshake shack coding problem.Last reply 4 months ago
How do you practice programming java for beginners?Last reply 8 months ago
iDEA run code error worker resolution badgeLast reply 1 month ago
Free website hosting providers with no strings attached?Posted 3 months ago
iDEA silver citizen badge three. Milkshake shack coding problem.Last reply 4 months ago
How do you practice programming java for beginners?Last reply 8 months ago
iDEA run code error worker resolution badge