예제 #1
0
 public void Validate()
 {
     if (Value > LuckyList.Last())
     {
         Validations.Add("Invalid Lucky List or Number");
     }
 }
예제 #2
0
        public bool Lucky()
        {
            if (!Valid || Value % 2 == 0)
            {
                return(false);
            }

            int position = 0, number = 0;

            LuckyList.RemoveAll(x => x % 2 == 0);

            while (position < LuckyList.Count && number < LuckyList.Count)
            {
                number = LuckyList[position];
                position++;

                if (number == 1)
                {
                    continue;
                }

                var removeList = new List <int>();

                for (var index = number; index < LuckyList.Count; index += number)
                {
                    removeList.Add(LuckyList[index - 1]);
                }

                LuckyList.RemoveAll(x => removeList.Contains(x));
            }

            return(LuckyList.Contains(Value));
        }