Computer Science, asked by kotgiregeeta9342, 1 year ago

Javascript program to generate the series of prime numbers between 1 to 100 using recursive function

Answers

Answered by amankumaraman11
0

hope this helps you...

Attachments:
Answered by Harshitm077
0

Answer:

After using this code provided in this explanation, only one thing which could anyone do that it needs to put the value of N = 100 & after this, you'll get the answer like this -  2 3 5 7 11 13 17 19 23 29 31 37 41 43 47 53 59 61 67 71 73 79 83 89 97

Explanation:

import java.util.Scanner;

public class PrintPrimeNumber {

static int CheckPrime(int i,int num)

{

    if(num==i)

        return 0;

    else

        if(num%i==0)

            return 1;

    else{

        return CheckPrime(i+1,num);

    }

}

public static void main(String[] args) {

 Scanner cs=new Scanner(System.in);

    int n;

    System.out.print("Enter the N Value:");

    n=cs.nextInt();

    System.out.print("Prime Number Between 1 to n are: ");

    for(int i=2;i<=n;i++)

     if(CheckPrime(2,i)==0)

      System.out.print(i+" ");

    cs.close();

}

}

Input/Output:

Enter the N Value = 100

Prime Number Between 1 to 100 are:  2 3 5 7 11 13 17 19 23 29 31 37 41 43 47 53 59 61 67 71 73 79 83 89 97

For more answers - https://www.quora.com/How-can-I-print-prime-numbers-between-1-to-100-using-recursion-in-C

Similar questions