2-digit

How many 2-digit prime numbers are there?


The answer is 21.

This section requires Javascript.
You are seeing this because something didn't load right. We suggest you, (a) try refreshing the page, (b) enabling javascript if it is disabled on your browser and, finally, (c) loading the non-javascript version of this page . We're sorry about the hassle.

4 solutions

Pappala Lokesh
Mar 5, 2014

below 100, 25 prime numbers are there, 25-4=21(4 means 2,3,5,7)

S W
Apr 21, 2014

class Program {

    static int[] results = new int[25];
    static void Main(string[] args)
    {
        Console.WriteLine(GetAllPrime(out results));
        for (int i = 0; i < results.Count(); i++) 
        {
            Console.WriteLine("Number Prime is " + results[i]);

        }
        Console.ReadLine();

    }
    public static int GetAllPrime(out int[] result)
    {
        result = new int[25];
        int innerCount = 0;
        int finalCount = 0;
        for (int i = 10; i <= 99 ; i++) 
        {
            for (int j = 2; j <= i; j++) 
            {
                if (i % j == 0)
                    innerCount++;
            }
            if (innerCount == 1)
            {
                result[finalCount] = i;
                finalCount++;
            }
            innerCount = 0;
        }

        return finalCount;
    }
}
Ganesh Kumar
Mar 20, 2014

11 13 17 19 23 29 31 37 41 43 47 53 59 61 67 71 73 79 83 89 97

Sandeep Thakur
Mar 4, 2014

Javascript Solution

from  = parseInt(window.prompt("Starting From"));
to = parseInt(window.prompt("Up to"));
count = 0;

for(i=from; i<=to; i++){
    flag = false;
    for(j=2; j<=Math.sqrt(i); j++){
        if(i%j==0){
            flag = true;
            break;
        }
    }
    if(!flag){
        count++;
    }
}

alert("Total Prime numbers between " + from + " to " + to + " are " + count);

0 pending reports

×

Problem Loading...

Note Loading...

Set Loading...