분류 전체보기
-
프로젝트 오일러 5번배움/알고리즘 2019. 1. 25. 01:38
Smallest multipleProblem 52520 is the smallest number that can be divided by each of the numbers from 1 to 10 without any remainder.What is the smallest positive number that is evenly divisible by all of the numbers from 1 to 20? 최소 공배수를 구하는 문제다. 두 수의 최소 공배수라면 아주 쉽겠지만 1부터 20까지의 최소 공배수를 구하라는 문제로, for문으로 모두 확인하는 과정은 너무 시간이 오래걸린다. 얼마나 오래걸리나 확인해봤다. import time def isit(num): for a in range(2,20): if..
-
프로젝트 오일러 4번배움/알고리즘 2019. 1. 24. 21:16
4번 Largest palindrome productA palindromic number reads the same both ways. The largest palindrome made from the product of two 2-digit numbers is 9009 = 91 × 99.Find the largest palindrome made from the product of two 3-digit numbers. palindrome 은 우리말로 회문이다. 풀어말하자면 앞으로 읽으나 뒤로 읽으나 같은 것을 말한다. ex ) 토마토, 12321 3-digit number는 세 자리수. 즉 문제에서는 두 3자리 수의 (계산)결과물 중 가장 큰 회문을 찾으라는 것이 된다. 가장 큰 수를 찾아야하니 당연히 ..
-
파이썬 공부 프로젝트 오일러 (1~3)배움/알고리즘 2019. 1. 23. 21:22
파이썬 스킬을 어떻게 쌓을 수 있을까 고민 하다가 영어도 공부할겸 프로젝트 오일러에서 문제를 풀고 있다. https://projecteuler.net/ 1번은 너무 쉬워서 2번부터 배운 것을 기록하려한다. 프로젝트 오일러는 문제를 맞추고 나면 사람들과 정답을 공유하는 게시판이 있어 다른 사람들의 코딩 스킬을 배우기 좋았다. 2번 문제는 아래와 같다. 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 term..
-
Javascript foreach와 for문에서의 return문배움 2019. 1. 18. 20:11
지금까지는 forEach문과 for문을 구조적으로 같다고 생각하고 사용하였으나 (lambda식과 일반식) nodejs를 공부하던 중 return을 사용하여 실행중인 함수를 빠져나가려는 상황에서는 람다쪽에서 문제가 발생하는 것이 확인되었다. users.forEach((user) =>{ if(username == user.username && password == user.password){ req.session.displayName = user.displayName; return req.session.save(() => { res.redirect('/welcome'); }); } }); for(var i =0;i { res.redirect('/welcome'); }); } } 위의 코드에서 return은 ..