programmers level1 알고리즘 문제 - 콜라츠 추측

먼저, 문제부터~!


내가 푼 코드 :


num을 long타입으로 변환해준 이유는 num이 홀수일 경우 3을 곱하게 되는데
여기서 int 타입의 범위를 벗어날 수 있기때문에 long타입으로 형변환을 해주었다.
데이터가 int 타입의 범위를 벗어나게 되면 데이터 손실이 일어나서
예상한 결과와 다르게 연산이 되어 버리기 때문이다.

댓글

이 블로그의 인기 게시물

About JVM Warm up

About idempotent

About Kafka Basic

About ZGC

sneak peek jitpack

Spring Boot Actuator readiness, liveness probes on k8s

About Websocket minimize data size and data transfer cost on cloud

About G1 GC

대학생 코딩 과제 대행 java, python, oracle 네 번째