MapleStory Finger Point

๐Ÿƒ‍โ™‚๏ธBaekjoon/Python

#11653 - python ์†Œ์ธ์ˆ˜๋ถ„ํ•ด

HYEJU01 2024. 5. 18. 23:58
์ฒด๊ฐ Level : โ˜…โ˜…โ˜†
Review:  ์†Œ์ธ์ˆ˜๋ถ„ํ•ด ๊ตฌํ˜„ 

 

 

๐Ÿ’ก ์†Œ์ธ์ˆ˜๋ถ„ํ•ด ๊ฒฐ๊ณผ(์†Œ์ธ์ˆ˜)๋ฅผ ์˜ค๋ฆ„์ฐจ์ˆœ์œผ๋กœ ์ถœ๋ ฅํ•˜๋Š” ๋ฌธ์ œ

https://blog.iammathking.com/math-concept/226

 

๐Ÿ’ฌ ์†Œ์ธ์ˆ˜ : ์•ฝ์ˆ˜ ์ค‘์— ์†Œ์ˆ˜ ์ธ ๊ฒƒ

๐Ÿ’ฌ ์†Œ์ธ์ˆ˜๋ถ„ํ•ด : ์ˆซ์ž๋ฅผ ์†Œ์ˆ˜๋กœ ๋‚˜๋ˆ„๋Š” ๊ณผ์ •

 

์ˆซ์ž๋ฅผ ์†Œ์ˆ˜๋กœ๋งŒ ๋‚˜๋ˆ ์•ผํ•œ๋‹ค.

 

 

 

 

 

 

 

 

 

 

 

 

 


[์„ฑ๊ณต] 

 

์—ฌ๊ธฐ์„œ num ์€  ์†Œ์ˆ˜๊ฐ€ ๋˜๊ณ 

N ์ด 1์ด ๋˜๊ธฐ์ „๊นŒ์ง€ ๊ณ„์†ํ•ด์„œ (์•ฝ์ˆ˜ ์ค‘)์†Œ์ˆ˜ = num ๋กœ๋งŒ ๋‚˜๋ˆ ์ค€๋‹ค.

!!๋‹ค ๋‚˜๋ˆ ์คฌ์œผ๋ฉด ๋‹ค์‹œ 2๋กœ ์ดˆ๊ธฐํ™”ํ•ด์ค˜์•ผํ•œ๋‹ค!

else _ 0์œผ๋กœ ๋–จ์–ด์ง€์ง€ ์•Š๋Š”๋‹ค๋ฉด 0์œผ๋กœ ๋‚˜๋ˆ„์–ด๋–จ์–ด์งˆ๋•Œ๊ฐ€์ง€ num ์„ ์ฆ๊ฐ€์‹œ์ผœ์ค€๋‹ค.

 

N = int(input())
num = 2

while N!=1:
    if (N % num == 0):
        N = N//num
        print(num)
        num = 2
    else:
        num += 1

 

 

[์‹คํŒจ]  2,3 ์œผ๋กœ๋งŒ ๋ถ„ํ•ด๊ฐ€ ์•ˆ๋˜๋Š” ์ˆ˜๋„ ์žˆ๋‹ค 

๋ฐ˜๋ก€ ) 9991

์ฆ‰ ์†Œ์ˆ˜๋กœ๋งŒ ํ•  ์ˆ˜ ์žˆ๋„๋ก ์œ ๋™๊ฐ’์„ ์ง€์ •ํ•ด์ค˜์•ผํ•œ๋‹ค.

N = int(input())

while (True):
    if ( N % 2 == 0):
        print(2)
        N = int(N/2)
    elif (N % 3 == 0):
        print(3)
        N = int(N/3)
    else:
        break