Question:

write a c programe to generate prime numbers till the given number using for loo?

by Guest2623  |  8 years, 10 month(s) ago

0 LIKES UnLike

write a c programe to generate prime numbers till the given number using  for loo?

 Tags: generate, loo, prime, programe, till, Using, write

   Report

2 ANSWERS

  1. paafamily
    using System;
    using System.Collections.Generic;
    using System.Linq;
    using System.Text;

    namespace ConsoleApplication16
    {
        class Program
        {


            void prime_num(long num)
            {

                bool isPrime = true;
                for (int i = 0; i <= num; i++)
                {
                    for (int j = 2; j <= num; j++)
                    {
                        if (i != j && i % j == 0)
                        {
                            isPrime = false;
                            break;
                        }
                    }
                    if (isPrime)
                    {
                    Console .WriteLine ( "Prime:" + i );
                    }
                    isPrime = true;
                }
            }



            static void Main(string[] args)
            {
                Program p = new Program();
                p.prime_num (999999999999999L);
                Console.ReadLine();

            }
        }
    }

  2. Guest1518
    with using c
Sign In or Sign Up now to answser this question!

Question Stats

Latest activity: 10 years, 8 month(s) ago.
This question has 2 answers.

BECOME A GUIDE

Share your knowledge and help people by answering questions.