We use cookies to ensure you have the best browsing experience on our website. Please read our cookie policy for more information about how we use cookies.
  • HackerRank Home

    HackerRank

  • |
  • Prepare
  • Certify
  • Compete
  • Apply
  • Hiring developers?
  1. All Contests
  2. ProjectEuler+
  3. Project Euler #179: Consecutive positive divisors
  4. Discussions

Project Euler #179: Consecutive positive divisors

Contest ends in
Problem
Submissions
Leaderboard
Discussions

    You are viewing a single comment's thread. Return to all comments →

  • avjtndy
    4 years ago+ 0 comments

    Can anyone tell me what am I missing?? I am able to pass test case 0 not rest of them . Please help thank you

    con <- file("stdin", open = "r")
    data <- as.numeric(readLines(con))
    
    for (i in 1:data[1]){
        I <- data[i+1]
        n <- array(0,dim = I)
    for (i in 1:floor((I-1)/2)){
      for (j in seq(i*2,I, by = i)){
        n[j]= n[j]+1
      } 
     }
     b <- 0
     for(i in 2:I){
      if((n[i]==n[i-1])==TRUE){
        b <- b+1
      }
     }
         cat(b,sep = "\n")
    }
    
    0|
    Permalink
  • Blog
  • Scoring
  • Environment
  • FAQ
  • About Us
  • Support
  • Careers
  • Terms Of Service
  • Privacy Policy