In: Computer Science
i need a phone number with 9 digits but those digits should use only one time and be dividable by 3-5-7-11-13-17 numbers.the phone number must not contain 0. Write a code with c sharp.
note: answer is 869143275. i need to find this phone number
//C# program
using System;
class Main {
public static bool isValid(int num){
bool [] digits = new
bool[10];
bool valid = true;
for(int
i=0;i<10;i++)digits[i] = false;
while(num > 0){
digits[num%10] = true;
num/=10;
}
for(int
i=1;i<10;i++){
valid &= digits[i];
}
return valid &
!digits[0];
}
static void Main() {
for(int i=100000000 ;
i<=999999999;i++){
if(i%3==0 &&
i%5==0 && i%7==0 && i%11==0 && i%13==0
&& i%17==0){
if(isValid(i)) Console.WriteLine(i);
}
}
}
}