Skip to main content
Code Review

Return to Question

Commonmark migration
Source Link

2520 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?

2520 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?

2520 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?

deleted 5 characters in body; edited tags; edited title
Source Link
Jamal
  • 35.2k
  • 13
  • 134
  • 238

Problem 5 on Project Euler Smallest Multiple

The logic behind my algorithm is simple:

The number in question must be divisible by all of the numbers between 1 and 20 (assume inclusive for the ranges). As a result, it must be divisible by all of the numbers between 1 and 10. The smallest number that is divisible by all the numbers between 1 and 10 (given by Project Euler) is 2520. Thus, the number in question must be a multiple of 2520. (As I'm writing this, I'm starting to question whether or not this is a necessary truth, but the program does work. Don't really want to go about proving it right now. I'm fairly certain however.) Thus, I can start at 2520 + 2520 and simply add 2520 every iteration.

Edit: I made this quick program to check my math regarding my statement "Thus, the number in question must be a multiple of 2520." It returns true if it finds a number not divisible by 2520 but divisible by all of the numbers between 1 and 10, and false if it does not find such a number. I feel that I set the limit to a reasonable limit. It indeed returns false.

Problem 5 on Project Euler

The logic behind my algorithm is simple: The number in question must be divisible by all of the numbers between 1 and 20 (assume inclusive for the ranges). As a result, it must be divisible by all of the numbers between 1 and 10. The smallest number that is divisible by all the numbers between 1 and 10 (given by Project Euler) is 2520. Thus, the number in question must be a multiple of 2520. (As I'm writing this, I'm starting to question whether or not this is a necessary truth, but the program does work. Don't really want to go about proving it right now. I'm fairly certain however.) Thus, I can start at 2520 + 2520 and simply add 2520 every iteration.

Edit: I made this quick program to check my math regarding my statement "Thus, the number in question must be a multiple of 2520." It returns true if it finds a number not divisible by 2520 but divisible by all of the numbers between 1 and 10, and false if it does not find such a number. I feel that I set the limit to a reasonable limit. It indeed returns false.

Smallest Multiple

The logic behind my algorithm is simple:

The number in question must be divisible by all of the numbers between 1 and 20 (assume inclusive for the ranges). As a result, it must be divisible by all of the numbers between 1 and 10. The smallest number that is divisible by all the numbers between 1 and 10 (given by Project Euler) is 2520. Thus, the number in question must be a multiple of 2520. (As I'm writing this, I'm starting to question whether or not this is a necessary truth, but the program does work. Don't really want to go about proving it right now. I'm fairly certain however.) Thus, I can start at 2520 + 2520 and simply add 2520 every iteration.

I made this quick program to check my math regarding my statement "Thus, the number in question must be a multiple of 2520." It returns true if it finds a number not divisible by 2520 but divisible by all of the numbers between 1 and 10, and false if it does not find such a number. I feel that I set the limit to a reasonable limit. It indeed returns false.

Tweeted twitter.com/#!/StackCodeReview/status/217793195604586496
edited tags; edited title
Link
palacsint
  • 30.3k
  • 9
  • 82
  • 157

Problem 5 on Project Euler (Java)

added 942 characters in body
Source Link
Sephallia
  • 233
  • 1
  • 2
  • 6
Loading
Source Link
Sephallia
  • 233
  • 1
  • 2
  • 6
Loading
lang-java

AltStyle によって変換されたページ (->オリジナル) /