Click here to Skip to main content
15,886,919 members
Home / Discussions / C#
   

C#

 
AnswerRe: Windows Form Application! Pin
Killzone DeathMan30-Nov-12 1:28
Killzone DeathMan30-Nov-12 1:28 
QuestionBest practices for security implementation in RESTful api services using WCF/WebApi Pin
Md. Marufuzzaman24-Nov-12 1:21
professionalMd. Marufuzzaman24-Nov-12 1:21 
AnswerRe: Best practices for security implementation in RESTful api services using WCF/WebApi Pin
Eddy Vluggen24-Nov-12 5:08
professionalEddy Vluggen24-Nov-12 5:08 
GeneralRe: Best practices for security implementation in RESTful api services using WCF/WebApi Pin
Md. Marufuzzaman24-Nov-12 5:44
professionalMd. Marufuzzaman24-Nov-12 5:44 
AnswerRe: Best practices for security implementation in RESTful api services using WCF/WebApi Pin
Eddy Vluggen24-Nov-12 8:38
professionalEddy Vluggen24-Nov-12 8:38 
GeneralRe: Best practices for security implementation in RESTful api services using WCF/WebApi Pin
Md. Marufuzzaman24-Nov-12 22:06
professionalMd. Marufuzzaman24-Nov-12 22:06 
GeneralRe: Best practices for security implementation in RESTful api services using WCF/WebApi Pin
Eddy Vluggen25-Nov-12 3:54
professionalEddy Vluggen25-Nov-12 3:54 
QuestionPrime numbers and subtraction problems... Pin
sourpet24-Nov-12 0:55
sourpet24-Nov-12 0:55 
Hello everyone,

I'm currently working on a calculator and in order to challenge myself, I decided not to use any loops (while, for, ...) but only use recursive methods (if ... then ... return else return).

So basically what I'm trying to do is create a function that checks if the 2 numbers I've entered are primes numbers and if so, it subtract number A with number B. If the result is 6 then true, else false. A and B may not be greater than 1,000.

Here goes my code:

C#
static bool prime_6(int a, int B)/>/>
{
    int x;
    x = 2; // this number will divide number a and b to check if they are prime numbs.

        if (a < 1000 && b < 1000) //setting an exception
        {
            if (a % x != 0 && x < a) // Checking if number a is a prime number.
            {
            }
            if (b % x != 0 && x < B)/>/> // Checking if number b is a prime number.
            {
                x++;                   // Adding +1 to x
                return is_sexy(a, B)/>/>; // Launching back the function
            }

            return (a - b == 6); // Once it's done (if number a and b are prime, test if a - b = 6)
        }

        else
        {
            return false; // Otherwise false

    }

}


Now, I know some things I've done wrong: setting the "x=2" at the begining will always set my x to 2 and thus never ending the function but I don't see where to place it... any ideas ? Or improvement ? Or other mistakes ?

Thanks in advance.
AnswerRe: Prime numbers and subtraction problems... Pin
Eddy Vluggen24-Nov-12 5:06
professionalEddy Vluggen24-Nov-12 5:06 
AnswerRe: Prime numbers and subtraction problems... Pin
PIEBALDconsult24-Nov-12 6:12
mvePIEBALDconsult24-Nov-12 6:12 
QuestionC# ActiveX DLL, JavaScript run EXE Pin
Joni_7823-Nov-12 7:48
Joni_7823-Nov-12 7:48 
AnswerRe: C# ActiveX DLL, JavaScript run EXE Pin
Eddy Vluggen24-Nov-12 5:05
professionalEddy Vluggen24-Nov-12 5:05 
GeneralRe: C# ActiveX DLL, JavaScript run EXE Pin
Joni_7824-Nov-12 5:20
Joni_7824-Nov-12 5:20 
GeneralRe: C# ActiveX DLL, JavaScript run EXE Pin
Eddy Vluggen24-Nov-12 5:32
professionalEddy Vluggen24-Nov-12 5:32 
GeneralRe: C# ActiveX DLL, JavaScript run EXE Pin
Joni_7824-Nov-12 20:52
Joni_7824-Nov-12 20:52 
GeneralRe: C# ActiveX DLL, JavaScript run EXE Pin
Eddy Vluggen25-Nov-12 3:57
professionalEddy Vluggen25-Nov-12 3:57 
Questionalpha numeric char Pin
Member 945456322-Nov-12 23:02
Member 945456322-Nov-12 23:02 
AnswerRe: alpha numeric char Pin
Pete O'Hanlon22-Nov-12 23:05
mvePete O'Hanlon22-Nov-12 23:05 
GeneralRe: alpha numeric char Pin
Member 945456322-Nov-12 23:10
Member 945456322-Nov-12 23:10 
GeneralRe: alpha numeric char Pin
Pete O'Hanlon22-Nov-12 23:12
mvePete O'Hanlon22-Nov-12 23:12 
AnswerRe: alpha numeric char Pin
BobJanova22-Nov-12 23:27
BobJanova22-Nov-12 23:27 
AnswerRe: alpha numeric char Pin
V.23-Nov-12 0:06
professionalV.23-Nov-12 0:06 
GeneralRe: alpha numeric char Pin
Richard MacCutchan23-Nov-12 1:46
mveRichard MacCutchan23-Nov-12 1:46 
GeneralRe: alpha numeric char Pin
DaveAuld23-Nov-12 3:02
professionalDaveAuld23-Nov-12 3:02 
GeneralRe: alpha numeric char Pin
V.23-Nov-12 3:23
professionalV.23-Nov-12 3:23 

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.