본문 바로가기

Math🥸4

4. Largest Palindrome Product 제일 큰 대칭수 찾기 문제 A palindromic number reads the same both ways. The largest palindrome made from the product of two 2-digit numbers is 9009 = 91 x 99Find the largest palindrome made from the product of two 3-digit numbers.3자리숫자 두개를 곱했을 때 최댓값의 대칭수를 찾는 문제1. -1했을 때 같은지를 판단하는 def를 먼저 만든다.for i in range(999, 99, -1):     for j in range(i, 99, -1):         product = i * j        만약 -1했을때 같은지 판별했을떄      .. 2024. 12. 8.
3. Largest Prime Factor The prime factors of 13195 are 5, 7, 13 and 29What is the largest prime factor of the number 600851475143-for in으로 하려니, 숫자를 2부터~~ 설정된 수 까지 너무 많은 경우를 거침-While로 반복문을 걸어서 입력수 n이  나눠짐가능한 소인수를 찾으면 - 나눠진 새로운 수로 n을 재설정 - 소인수i가 n보다 작을때만 계속 반복하고  -반복문안에선  나눠지는수인지vs아닌지 판별-나눠지면 소인수list에 추가하고 n을 나눠 재할당하고 -안나눠지면 그냥 카운트n=int(input())prime_factor=[]i=2while i 1: prime_factor.append(n)print(prime_factor)prin.. 2024. 11. 12.
2. Even Fibonacci Numbers Each new term in the Fibonacci sequence is generated by adding the previous two terms. By starting with 1 and 2, the first 10 terms will be:1,2,3,5,8,13,21,34,55,89,…By considering the terms in the Fibonacci sequence whose values do not exceed four million, find the sum of the even-valued terms.-피보나치 설명 블라블라- Generate 2 value A,B-A,B는 매번 새 값 넣어줘야함 (전값,더한값)- A    항 자체가 숫자넘지않도록    (bellow는 미만이지만 d.. 2024. 11. 7.
1. Multiples of 3 or 5 bellow 1000 ,즉 1000 미만의 수 중 3과 5의 배수를 곱해주면 되는 문제.숫자 하나 하나 속성을 비교해서 판별해 추가하는 건  for in loop.sum=0for i in range(1000): if i%3==0 or i%5==0: sumlist.append(i) sum+=i 2024. 11. 7.