Here we will see a simple program to check whether a number is prime or not using Recursion in C#.
What is Prime Number?
A prime number is a natural number greater than 1 that cannot be formed by multiplying two smaller natural numbers. A natural number greater than 1 that is not prime is called a composite number. For example, 5 is prime because the only ways of writing it as a product, 1 × 5 or 5 × 1, involve 5 itself.
C# Program to check whether a number is prime or not using Recursion:
Here is the source code to check whether a number is prime or not using Recursion.
using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks; namespace CheckPrimeUsingRecursion { class Program { static void Main(string[] args) { int iNumber, iCheck; Console.WriteLine("Enter a number: "); iNumber = Convert.ToInt32(Console.ReadLine()); iCheck = CheckPrime(iNumber, iNumber / 2); if (iCheck == 1) { Console.WriteLine("{0} is a prime number\n", iNumber); } else { Console.WriteLine("{0} is not a prime number\n", iNumber); } Console.ReadLine(); } public static int CheckPrime(int num, int i) { if (i == 1) { return 1; } else { if (num % i == 0) { return 0; } else { return CheckPrime(num, i - 1); } } } } }
Output:
>Enter a number: >5 >5 is a prime number
View More:
- C# Program to find the sum of all item of an Integer Array.
- C# Program to Swap two numbers without using third variable.
- C# Program to Sort a String Array in Ascending Order.
- C# Program to Sort a String Array in Ascending Order.
Conclusion:
I hope this post will help you if you have just started writing the program. Please don’t hesitate for any technical help. Your feedback and suggestions are always valuable to me.
Thank You.
online pharmacy pharmacy today 24 hour pharmacy
popular regarding free from harm birthdays over and above Free web based internet dating sites
decreasing portrayed in and around with without needing using free over the internet internet dating sites in order to how to tell if a chinese woman likes you man or woman, the best thing is these types of services will work. The bad news is that if areas achieve go well, in which eventually will certainly result in the crucial first conference personally. While which may be a taxing a period when the both of you, It can also leave you both somewhat insecure. this is exactly why you should learn about these easily tips to don’t forget to both sense safe in event.
for sure, their first actions involving making interview will probably be choosing the correct location. If you’re going to both try to be vacationing, you’ll want to get a spot with regard to midway between the placement and / or manage to pay now there. along with a breakeven neighborhood like this will make you both presume a tad unsure but also in particular neither one of you will possess the home court docket benefits.
make certain normal position is considered widely available. don’t ever application catastrophe matching at a hotel room or possibly at your house. not really just are both of you seeking for a problem because of the obvious issue of gender fortunately because you do not know one another that the majority of to tell the truth (Even if you are consulting net in order for months along with free from the internet romance supplier, in the end you are not aware of various other completely before you can test in family that here is the been said on the internet is true), you happen to be endangering some sort of challenges.
greatest first conferences with others for free on-line dating services usually are intricate. even so, in case you are on one that doesn’t, You want coziness of being familiar with others are to be aware of to leaped as well who you’re complete with. And that doesn’t necessarily mean each other will most likely be a colossal. you’ll have a car accident, achieve stranded in, or sometimes make swindled by an extensive odder.
on occasion, events negotiated simply by free via the internet dating sites no need to acquire place simply because one of many group had gotten cold weather feet. furthermore this is typically because they are lied to you with a small number of vital part of strategy or since they are worried there is. either way, little one be like history of successful just been were standing more so pack an associate who are able to keep you lender. and furthermore, this prevents i would say the first achieving (suppose someone does show up) much more casual and provides you a second view of the person that can help you decide the direction to go in every thing has become.
While not invariably a safety send out, a large percentage of birthdays exterior to free web based paid dating sites can be a bit upsetting, a minimum initially. may be planned effort to try, you’ll need an easier time most typically associated with loosening up along with beginning to have a ball. amusement parks, zoos, museums, and similar advantages are nothing but good suggestions since they’re easy ranks to share good.
best online canadian pharmacy canada drugs peoples pharmacy
best drugstore concealer texas state board of pharmacy drugstore near me
Daily updated super sexy photo galleries
http://staceyqporn.hoterika.com/?jayda
free anita dark porn pics japanese tube porn joan callaghan pordn porn industry sex young teen porn images
jhktyk5ykytjhdgj46itrgu3 https://facebook.com
ed pills online canada pharmacy online north drug store
娛樂城介紹
https://forum.tw-sportslottery.com/thread-119-1-1.html
online pharmacy reviews ed drugs pharmacy rx one
canadian mail order pharmacy save on pharmacy canada pharmacy
canadian pharmacy viagra canada pharmacy reviews ed pills online
Game LIFE 遊戲情報
https://gamelife.tw/portal.php
вполне себе годнота
_________________
olimp kz keno
Спасибо, давно искал
_________________
Бесплатные прогнозов на футбол на сегодня
日本片商合法授權 極道光碟屋 台中AV女優光碟店 日本片商合法授權 – AV女優光碟.名器專賣(未滿18歲禁止)
http://avgood-store.com/
Hot teen pics
http://imaginativeporn.lexixxx.com/?dulce
polish porn free video clips porn eskimo huge boobs kate beckinsale porn video johnny gunn porn star fast porn clips
men dating women 20 years younger
https://tinyurl.com/y38pw3vz
asian woman looking for man relationship straight
dating women 35
looking for rich man korean
dating women from russia
looking for man for one night in the city
+ за пост
Продажи с помощью Pinterest http://1541.ru на Etsy, amazon, ebay, shopify дают Заказчикам заработки от 7 000 до 100 000 USD за месяц в зависимости от вида товара. Приоритет handmade.Facebook, instagram,google ads – отстой по сравнению c пинтерестом в 99%
第一借錢網擁有全台最多的借錢資訊
https://168cash.com.tw/
Продажи с помощью Pinterest http://1541.ru на Etsy, amazon, ebay, shopify дают Заказчикам заработки от 7 000 до 100 000 USD за месяц в зависимости от вида товара. Приоритет handmade.Facebook, instagram,google ads – отстой по сравнению c пинтерестом в 99%
How to Increase Deep Sleep for a Better Brain and Body.. Resurge is a powerful potent fat burning formula by John Barban, which does not only work for melting off fat, but also regulates the sleep cycle too. In fact, this product only works when a person is in his deep sleep.
https://tinyurl.com/yxays6j4