Creating a 6 digit password

Hello,
I need help with a following project. I am suppose to create a code that allows a user to put in a six digit password and it has to follow the following:

1) The password must be six digits long no more no less, and can't have leading zeros.
2)All the digits in the number must be unique
3)The sum of the digits have to be a prime number
4)The largest digit (n) "choose" the left-most digit (k) must be even-for example: in 645923, the largest digit is 9 and left-most is 6. Note: n "choose" k is computed via: (n!)/(k!(n-k)!)

Where ! denotes a factorial. For example 3 choose 2 is: 3*2*1/((2*1)*1)=3

This is what I have so far:



#include <iostream>
#include <fstream>
#include <cmath>
#include <string>

using namespace std;

int main()
{
int num=0;

cout << "Enter six digit code." << endl;
cin >> num;


while (num>999999 || num<100000){

cout <<"code doesn't have six digits." << endl;
cout <<"Enter six digit code." ;
cin >> num;
}
cout << num << endl;

//Exit program
return 0;
Last edited on
At least try to code something, don't just ask someone to do it for you.
Show us that you want to learn.
Last edited on
Topic archived. No new replies allowed.