Good Day,
I'm trying to make a code that would determine the prime numbers between two numbers. This should be done recursively and without any loop. So far I have this code:
#include<stdio.h>
#include<conio.h>
void prime(int x, int y){
int waa;
if(x <= y){
waa = isPrime(x);
if(waa==1 || waa == 0){
printf("");
}else{
printf("%5d",waa);
}
prime(x+1,y);
}
}
int isPrime(int n, int i){
i = 2;
if(i<n){
if(n%i==0 && n!=2 && n!=i){
return(0);
}else{
return(n);
}
i++;
isPrime(n,i);
}
}
void main(){
int num[2];
clrscr();
printf("Input 2 numbers: \n");
scanf("%d %d", &num[0], &num[1]);
prime(num[0], num[1]);
getch();
}
the output between 1 and 10 is: 2,2,3,5,7,9. expected output: prime numbers 2,3,5,7
Would anyone be able to help me with this.
much appreciated
Thank you