Home > Programming > What is the smallest number divisible by each of the numbers 1 to 21?

What is the smallest number divisible by each of the numbers 1 to 21?


public class Projec {

public static void main(String[] args) {

out:for (int i = 2520; ; i++) {
for (int j = 2; j < 21; j++) {
if(i%j==0) ;
else
continue out;
}
System.out.println(“”+i);
break out;
}
}

}

But the true way of finding the number is as follows

To find a number that is divided by 1 to 6

is 1*2*3*2((4)because one 2 is already included)*5*(no need(2*3) already included)=60

1*2*3*2*5=60

FOR 1 to 21

2 * 3 * 2 * 5 * 7 * 2 * 3 * 11 * 13 * 2 * 17 * 19 = 232792560

Advertisements
Categories: Programming
  1. No comments yet.
  1. No trackbacks yet.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: