programmers level1 알고리즘 문제 - 정수제곱근판별하기 JavaScript, Python

function nextSqaure(n){
  var result = 0;
  var x = 0;
  //함수를 완성하세요
  for(;x*x<n;){
    x++;
  }
  if(x*x==n){
    x++;
  return x*x;
  }else{
    return "no";
  }
}

// 아래는 테스트로 출력해 보기 위한 코드입니다.
console.log("결과 : " + nextSqaure(121));






import math
def nextSqure(n):
    x = math.sqrt(n)
    if (int(x) == x):
        return pow(x+1,2)
    else:
       
    # 함수를 완성하세요
    return 'no'

# 아래는 테스트로 출력해 보기 위한 코드입니다.
print("결과 : {}".format(nextSqure(121)));

댓글

이 블로그의 인기 게시물

About Kafka Basic

About JVM Warm up

About idempotent

About G1 GC

About ZGC

Spring Boot Actuator readiness, liveness probes on k8s

sneak peek jitpack

Optimistic Concurrency Control VS Pessimistic Concurrency Control - What should i choose?

DDD(Domain Driven Design) - Aggregate (어그리게잇)

Strategy Pattern In Spring (feat. JPA)