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
  • Hiring developers?
  1. All Contests
  2. ProjectEuler+
  3. Project Euler #229: Four Representations using Squares
  4. Discussions

Project Euler #229: Four Representations using Squares

Problem
Submissions
Leaderboard
Discussions

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

  • yogeshprasad664
    4 years ago+ 0 comments

    def count(y): flag1 , flag2,flag3,flag4,count=0,0,0,0,0 for n in range(y): i = 1 while i * i <= n : j = i while(j * j <= n) : if (i * i + j * j == n) : flag1=1 if (i*i+2*j*j == n): flag2=1 if (i*i+3*j*j == n): flag3=1 if (i*i+7*j*j == n): flag4=1 j+=1 if flag1 is 1 and flag2 is 1 and flag3 is 1 and flag4 is 1: count+=1 break i+=1 flag1,flag2,flag3,flag4=0,0,0,0 n+=1; return count

    if name=='main': n=int(input().strip()) for i in range(n): x=int(input().strip()) r=count(x) print(r)

    I WAS DOING THE PROBLEM ON FOUR REPRESENTAION USING SQUARES.
    WELL THIS IS MY CODE AND I AM GETTING RUNTIME ERROR.PLEASE HELP ME RESOLVE THIS.

    0|
    Permalink
  • Blog
  • Scoring
  • Environment
  • FAQ
  • About Us
  • Support
  • Careers
  • Terms Of Service
  • Privacy Policy