{"id":"f06b54d5-4cee-4a61-b653-26f4e132cdba","name":"The Curious Case Of Benjamin Bulbs","description":"1. You are given n number of bulbs. They are all switched off. A weird fluctuation in voltage hits the circuit n times. In the 1st fluctuation all bulbs are toggled, in the 2nd fluctuation every 2nd bulb is toggled, in the 3rd fluctuation every 3rd bulb is toggled and so on. You've to find which bulbs will be switched on after n fluctuations.\r\n2. Take as input a number n, representing the number of bulbs.\r\n3. Print all the bulbs that will be on after the nth fluctuation in voltage.","inputFormat":"n, an integer","outputFormat":"b1 b2 b3 b4 .. all bulbs that will be on after nth wave","constraints":"2 &lt;= n &lt; 10^9","sampleCode":{"cpp":{"code":"#include<iostream>\r\nusing namespace std;\r\nint main(int argc, char**argv){\r\n int n;\r\n cin>>n;\r\n \r\n //write your code here\r\n \r\n}"},"java":{"code":"public class Main{\r\n public static void main(String args)\r\n {\r\n // Write your code here\r\n }\r\n}"},"python":{"code":"def main():\r\n \r\n\r\nif __name__ == \"__main__\":\r\n main()"}},"points":10,"difficulty":"easy","sampleInput":"6","sampleOutput":"1\r\n4","questionVideo":"https://www.youtube.com/embed/_F7ejdDCpyg","hints":[],"associated":[{"id":"89a5ae01-a3e4-4fa3-8670-96a493e40cf1","name":"What will be the output for 23?","slug":"what-will-be-the-output-for-23","type":4},{"id":"aeeeab19-8f06-4af3-9d47-f84c46b8e828","name":"fill the blank for this problem ?","slug":"fill-the-blank-for-this-problem","type":4},{"id":"de383ddf-d655-4e97-a31a-9f150eeb0646","name":"What is the time complexity for The Curious Case Of Benjamin Bulbs","slug":"what-is-the-time-complexity-for-the-curious-case-of-benjamin-bulbs","type":4}],"solutionSeen":false,"tags":[],"meta":{"path":[{"id":0,"name":"home"},{"id":"0c54b191-7b99-4f2c-acb3-e7f2ec748b2a","name":"Data Structures and Algorithms","slug":"data-structures-and-algorithms","type":0},{"id":"72157774-7fd0-4b8e-88dc-037800acd626","name":"Getting Started","slug":"getting-started-9996","type":0},{"id":"6ace02a5-2de9-4c01-80e0-626b252b35ea","name":"The Curious Case Of Benjamin Bulbs","slug":"the-curious-case-of-benjamin-bulbs","type":1}],"next":{"id":"b0493e4b-75e5-4164-9fc4-6c6811ca3f21","name":"The Curious Case Of Benjamin Bulbs","type":3,"slug":"the-curious-case-of-benjamin-bulbs"},"prev":{"id":"d0a17e65-2f5e-47d6-9c64-c653427b2499","name":"Pythagorean Triplet","type":3,"slug":"pythagorean-triplet"}}}

The Curious Case Of Benjamin Bulbs

1. You are given n number of bulbs. They are all switched off. A weird fluctuation in voltage hits the circuit n times. In the 1st fluctuation all bulbs are toggled, in the 2nd fluctuation every 2nd bulb is toggled, in the 3rd fluctuation every 3rd bulb is toggled and so on. You've to find which bulbs will be switched on after n fluctuations. 2. Take as input a number n, representing the number of bulbs. 3. Print all the bulbs that will be on after the nth fluctuation in voltage.

{"id":"f06b54d5-4cee-4a61-b653-26f4e132cdba","name":"The Curious Case Of Benjamin Bulbs","description":"1. You are given n number of bulbs. They are all switched off. A weird fluctuation in voltage hits the circuit n times. In the 1st fluctuation all bulbs are toggled, in the 2nd fluctuation every 2nd bulb is toggled, in the 3rd fluctuation every 3rd bulb is toggled and so on. You've to find which bulbs will be switched on after n fluctuations.\r\n2. Take as input a number n, representing the number of bulbs.\r\n3. Print all the bulbs that will be on after the nth fluctuation in voltage.","inputFormat":"n, an integer","outputFormat":"b1 b2 b3 b4 .. all bulbs that will be on after nth wave","constraints":"2 &lt;= n &lt; 10^9","sampleCode":{"cpp":{"code":"#include<iostream>\r\nusing namespace std;\r\nint main(int argc, char**argv){\r\n int n;\r\n cin>>n;\r\n \r\n //write your code here\r\n \r\n}"},"java":{"code":"public class Main{\r\n public static void main(String args)\r\n {\r\n // Write your code here\r\n }\r\n}"},"python":{"code":"def main():\r\n \r\n\r\nif __name__ == \"__main__\":\r\n main()"}},"points":10,"difficulty":"easy","sampleInput":"6","sampleOutput":"1\r\n4","questionVideo":"https://www.youtube.com/embed/_F7ejdDCpyg","hints":[],"associated":[{"id":"89a5ae01-a3e4-4fa3-8670-96a493e40cf1","name":"What will be the output for 23?","slug":"what-will-be-the-output-for-23","type":4},{"id":"aeeeab19-8f06-4af3-9d47-f84c46b8e828","name":"fill the blank for this problem ?","slug":"fill-the-blank-for-this-problem","type":4},{"id":"de383ddf-d655-4e97-a31a-9f150eeb0646","name":"What is the time complexity for The Curious Case Of Benjamin Bulbs","slug":"what-is-the-time-complexity-for-the-curious-case-of-benjamin-bulbs","type":4}],"solutionSeen":false,"tags":[],"meta":{"path":[{"id":0,"name":"home"},{"id":"0c54b191-7b99-4f2c-acb3-e7f2ec748b2a","name":"Data Structures and Algorithms","slug":"data-structures-and-algorithms","type":0},{"id":"72157774-7fd0-4b8e-88dc-037800acd626","name":"Getting Started","slug":"getting-started-9996","type":0},{"id":"6ace02a5-2de9-4c01-80e0-626b252b35ea","name":"The Curious Case Of Benjamin Bulbs","slug":"the-curious-case-of-benjamin-bulbs","type":1}],"next":{"id":"b0493e4b-75e5-4164-9fc4-6c6811ca3f21","name":"The Curious Case Of Benjamin Bulbs","type":3,"slug":"the-curious-case-of-benjamin-bulbs"},"prev":{"id":"d0a17e65-2f5e-47d6-9c64-c653427b2499","name":"Pythagorean Triplet","type":3,"slug":"pythagorean-triplet"}}}
plane

Editor


Loading...

The Curious Case Of Benjamin Bulbs

easy

1. You are given n number of bulbs. They are all switched off. A weird fluctuation in voltage hits the circuit n times. In the 1st fluctuation all bulbs are toggled, in the 2nd fluctuation every 2nd bulb is toggled, in the 3rd fluctuation every 3rd bulb is toggled and so on. You've to find which bulbs will be switched on after n fluctuations. 2. Take as input a number n, representing the number of bulbs. 3. Print all the bulbs that will be on after the nth fluctuation in voltage.

Constraints

2 <= n < 10^9

Format

Input

n, an integer

Output

b1 b2 b3 b4 .. all bulbs that will be on after nth wave

Example

Sample Input

6

Sample Output

1 4

Question Video

Discussions

Show Discussion

Related Resources

related resources

Turning Off Zen Mode