Click here to Skip to main content
15,900,511 members
Home / Discussions / C#
   

C#

 
GeneralRe: Emailing Image To Tumblr Pin
JBHowl6-Jan-15 3:43
JBHowl6-Jan-15 3:43 
AnswerRe: Emailing Image To Tumblr Pin
JBHowl10-Jan-15 2:48
JBHowl10-Jan-15 2:48 
QuestionTrouble handling DeviceIoControl to retrieve USN data Pin
Mandelnuss3-Jan-15 0:46
Mandelnuss3-Jan-15 0:46 
AnswerRe: Trouble handling DeviceIoControl to retrieve USN data Pin
Richard MacCutchan3-Jan-15 0:57
mveRichard MacCutchan3-Jan-15 0:57 
GeneralRe: Trouble handling DeviceIoControl to retrieve USN data Pin
Mandelnuss3-Jan-15 1:18
Mandelnuss3-Jan-15 1:18 
GeneralRe: Trouble handling DeviceIoControl to retrieve USN data Pin
Richard MacCutchan3-Jan-15 1:50
mveRichard MacCutchan3-Jan-15 1:50 
GeneralRe: Trouble handling DeviceIoControl to retrieve USN data Pin
Mandelnuss3-Jan-15 3:53
Mandelnuss3-Jan-15 3:53 
GeneralRe: Trouble handling DeviceIoControl to retrieve USN data Pin
Richard MacCutchan3-Jan-15 4:46
mveRichard MacCutchan3-Jan-15 4:46 
GeneralRe: Trouble handling DeviceIoControl to retrieve USN data Pin
Mandelnuss3-Jan-15 5:20
Mandelnuss3-Jan-15 5:20 
QuestionLogic of prime numbers Pin
Member 113371082-Jan-15 12:44
Member 113371082-Jan-15 12:44 
AnswerRe: Logic of prime numbers Pin
BillWoodruff2-Jan-15 13:14
professionalBillWoodruff2-Jan-15 13:14 
GeneralRe: Logic of prime numbers Pin
Richard MacCutchan2-Jan-15 22:03
mveRichard MacCutchan2-Jan-15 22:03 
GeneralRe: Logic of prime numbers Pin
Pete O'Hanlon2-Jan-15 23:23
mvePete O'Hanlon2-Jan-15 23:23 
GeneralRe: Logic of prime numbers Pin
BillWoodruff3-Jan-15 0:42
professionalBillWoodruff3-Jan-15 0:42 
GeneralRe: Logic of prime numbers Pin
Richard MacCutchan3-Jan-15 0:47
mveRichard MacCutchan3-Jan-15 0:47 
GeneralRe: Logic of prime numbers Pin
BillWoodruff3-Jan-15 11:57
professionalBillWoodruff3-Jan-15 11:57 
GeneralRe: Logic of prime numbers Pin
Richard MacCutchan3-Jan-15 21:05
mveRichard MacCutchan3-Jan-15 21:05 
GeneralRe: Logic of prime numbers Pin
BillWoodruff3-Jan-15 21:21
professionalBillWoodruff3-Jan-15 21:21 
GeneralRe: Logic of prime numbers Pin
Richard MacCutchan3-Jan-15 22:02
mveRichard MacCutchan3-Jan-15 22:02 
AnswerRe: Logic of prime numbers Pin
SledgeHammer012-Jan-15 14:16
SledgeHammer012-Jan-15 14:16 
GeneralRe: Logic of prime numbers Pin
Member 113371082-Jan-15 14:19
Member 113371082-Jan-15 14:19 
GeneralRe: Logic of prime numbers Pin
SledgeHammer012-Jan-15 14:32
SledgeHammer012-Jan-15 14:32 
GeneralRe: Logic of prime numbers Pin
Member 113371082-Jan-15 15:06
Member 113371082-Jan-15 15:06 
C#
Console.Write("Enter a Number : ");
           int num;
           num = Convert.ToInt32(Console.ReadLine());
           int k;
           k = 0;
           for (int i = 1; i <= num; i++)
           {
               if (num % i == 0)
               {
                   k++;
               }
           }
           if (k == 2)
           {
               Console.WriteLine("Entered Number is a Prime Number and the Largest Factor is {0}",num);
           }
           else
           {
               Console.WriteLine("Not a Prime Number");
           }
           Console.ReadLine();


you seem to be very smart. so heres one last question for you. In this situation, what does the k stand for? why is it that if k=2 then the number that was entered is prime?
GeneralRe: Logic of prime numbers Pin
SledgeHammer012-Jan-15 15:24
SledgeHammer012-Jan-15 15:24 
GeneralRe: Logic of prime numbers Pin
BillWoodruff3-Jan-15 11:59
professionalBillWoodruff3-Jan-15 11:59 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.