Skip to content
This repository has been archived by the owner on Aug 26, 2019. It is now read-only.

lucky number is implemented #91

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Empty file added src/factorial.js
Empty file.
35 changes: 35 additions & 0 deletions src/luckyNumber.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
#include<bits/stdc++.h>
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;
}