From 26e9bf8efabd466282c07299d877785f6ccf8fe2 Mon Sep 17 00:00:00 2001 From: Gupta Date: Fri, 31 May 2019 11:02:11 +0530 Subject: [PATCH] lucky number is implemented --- src/factorial.js | 0 src/luckyNumber.cpp | 35 +++++++++++++++++++++++++++++++++++ 2 files changed, 35 insertions(+) create mode 100644 src/factorial.js create mode 100644 src/luckyNumber.cpp diff --git a/src/factorial.js b/src/factorial.js new file mode 100644 index 0000000..e69de29 diff --git a/src/luckyNumber.cpp b/src/luckyNumber.cpp new file mode 100644 index 0000000..deb2702 --- /dev/null +++ b/src/luckyNumber.cpp @@ -0,0 +1,35 @@ +#include +using namespace std; + +bool luckyNumber(int n){ + + bool count[10]; + for(int i = 0;i<10;i++) + count[i] = 0; + + while(n > 0){ + int dig = n%10; + if(count[dig]) + return false; + n /= 10; + } + return true; + +} + +int main(){ + + int n; + cout<<"Enter a number :"; + cin>>n; + + bool ans = luckyNumber(n); + if(ans){ + cout<<"It is a lucky number"; + } + else{ + cout<<"It is not a lucky number"; + } + + return 0; +} \ No newline at end of file