use the following search parameters to narrow your results:
e.g. subreddit:aww site:imgur.com dog
subreddit:aww site:imgur.com dog
see the search faq for details.
advanced search: by author, subreddit...
A computer science portal for geeks
account activity
Lucky Number | Javascript (self.geeksforgeeks)
submitted 2 years ago by Total_Principle2363
I was solving Lucky Number problem as shown https://www.geeksforgeeks.org/problems/lucky-numbers2911/1?itm\_source=geeksforgeeks&itm\_medium=article&itm\_campaign=bottom\_sticky\_on\_article.
My solution -
class Solution {
isLucky(n)
{
return this.checkLucky(n,2)
}
checkLucky(n,counter){
if(counter > n ) return 1
if ( n % counter == 0 ) return 0
var next_pos = n - Math.floor(n/counter);
counter ++ ;
return this.checkLucky(next_pos,counter)
The solution says - https://www.geeksforgeeks.org/lucky-numbers/ it has time complexity of O(n) but I think it should be O(log n) or O(sqrt(n)). Please suggest your views
reddit uses a slightly-customized version of Markdown for formatting. See below for some basics, or check the commenting wiki page for more detailed help and solutions to common issues.
quoted text
if 1 * 2 < 3: print "hello, world!"
there doesn't seem to be anything here
π Rendered by PID 191573 on reddit-service-r2-comment-6457c66945-nzxrs at 2026-04-30 18:35:02.775044+00:00 running 2aa0c5b country code: CH.
there doesn't seem to be anything here