You are given infinite sequence of continuos natural numbers-1,2,3,4,5,6.......... Initially you delete every 2nd element so sequence will be 1,3,,5,7,9,11,13..... now in the resultant sequence you delete every third element i.e now 5,11...will be deleted. The numbers which will remain in sequence after infinite number of iterations are called lucky numbers(for e.g 1 is lucky number because it will be never deleted). WAP to check whether given number n is lucky or not

AnswerBot
1y

Program to check if a given number is a lucky number or not.

  • Create a function that takes an integer n as input

  • Initialize a variable count to 2

  • Loop through the sequence and delete every count-th elemen...read more

krushna Jadhav
3y
This is my c++ solution which check weather given number is lucky or not bool isLucky(int n){ return n %2 != 0 && (n - (n / 2)) % 3 != 0; }
Help your peers!
Add answer anonymously...
Microsoft Corporation Software Developer Interview Questions
Stay ahead in your career. Get AmbitionBox app
qr-code
Helping over 1 Crore job seekers every month in choosing their right fit company
65 L+

Reviews

4 L+

Interviews

4 Cr+

Salaries

1 Cr+

Users/Month

Contribute to help millions

Made with ❤️ in India. Trademarks belong to their respective owners. All rights reserved © 2024 Info Edge (India) Ltd.

Follow us
  • Youtube
  • Instagram
  • LinkedIn
  • Facebook
  • Twitter