ttmind

Main Navigation

ttmind
  • jim-jams
  • Tech
  • Positive
Login

Login

Facebook Google

OR

Remember me Forgot password?

Don't have account? Signup here.

Sort by Categorys

.Net

PHP

Java

JavaScript

Database

Server

Client Side

Tools

Artificial Intelligence

Cloud

Hybrid Development

Event

Smart City

Education

Security

Scrum

Digital Marketing

APP Development

Business

Internet

Simulation

Art

Network

Microservices

Architecture

Technology

Leadership

    Top Articles

  • How Does Social Media Bring People Together?
    TTMind Author
  • How to read appSettings JSON from Class Library in ASP.NET Core
    Anil Shrestha
  • Printing Support In Asp.Net Core
    TTMind Author
  • HOW TO EXTRACT TEXT FROM IMAGE USING JAVASCRIPT (OCR with Tesseract.js)?
    Prakash Pokhrel
  • Images Upload REST API using ASP.NET Core
    Prakash Pokhrel
  • Related Topic

  • How to read appSettings JSON from Class Library in ASP.NET Core
  • Printing Support In Asp.Net Core
  • Images Upload REST API using ASP.NET Core
  • How to use IActionFilter, IAsyncActionFilter in ASP.NET Core MVC?
  • ASP.NET CORE - Blazor CRUD operation using ADO.NET
  • Tech
  • About Us
  • Contact Us
  • TechHelp
  • PositiveHelp
  • Jim-Jams Help
  • Terms & Conditions

© Copyright ttmind.com

Main Content

Find prime porcupine number.

.Net C# about 7 years ago || 5/26/2019 || 3.5 K View

  • Hide

A prime number is an integer that is divisible by 1 an itself. A porcupine number is a prime number whose last digit is 9 and the next prime number that follows it also ends with the digit 9. For example 139 is a porcupine number because:

  •  It is prime
  •  It ends in a 9
  •  The next prime number after it is 149 which also ends in 9. Note that 140, 141, 142, 143, 144, 145, 146, 147 and 148 are not prime so 149 is the next prime number  after 139.

Write a function name isproc() that take two inputs from the user and print the prime porcument number between given ranges.

using System;

namespace porcupine
{
    class Program
    {
        public static void Main(string[] args)
        {
            Console.WriteLine("enter starting number ");
            int start = Convert.ToInt32(Console.ReadLine());

            Console.WriteLine("enter ending number ");
            int end = Convert.ToInt32(Console.ReadLine());
          
            Porcument objporcument = new Porcument();
            int answer= objporcument.isproc (start,end);
           
           
        }
    }
}




    public class Porcument
    {
        public int isproc(int start, int end)
        {
            int s = start, e = end;
            int i;
            for (i = s; i <= e; i++)
            {
                int c = 0;
                for (int j = 1; j <= e; j++)
                {
                    if (i % j == 0)
                    {
                        c++;
                    }
                 }
                if (c == 2)
                {
                    if (i % 10 == 9)
                    {
                        Console.WriteLine(i+ " is an Porcupine Number.");
                    }
                }
            }
            return 1;
        }
    }





 

 

 

  • 1
  • 0
  • 0
    • Facebook
    • Twitter
    • Google +
    • LinkedIn

About author

Asbin Joshi

Asbin Joshi

Reset Your Password
Enter your email address that you used to register. We'll send you an email with your username and a link to reset your password.

Quick Survey