## Pages

Showing posts with label addition. Show all posts
Showing posts with label addition. Show all posts

## Saturday, January 24, 2009

### How to add two numbers less than hundred rapidly

Adding two numbers less than 100 is easy. For instance, 29 + 45 = 74. However, how fast can you do it. Can you do at least sixty additions within one minute. Actually, you can do it, but, with some practices, using the simple technique that will be discuss in this article.

In order to add two numbers less than 100, add the tens first, instead of the ones. For example, to add 29 to 45, you do (29 + 40) + 5 = 69 + 5 = 74. As an addition, you should not say, either verbally or mentally, such as 29 and 40 are 69, 69 and 5 are 74. Instead, just say 69, 74.

23 + 48 = 63, 71
47 + 72 = 117, 119
79 + 69 = 139, 148

After some practices, the first reading should be left out. Thus the answer is gathered at once.

The only caveat to this technique is that, the calculation speed is proportional to the frequency of practices made. Without enough practices, you may not master this technique.

## Wednesday, April 16, 2008

### Problem #1 of Project Euler

Add all the natural numbers below 1000 that are multiples of 3 or 5.

### Analysis:

Sequence of multiple of 3: 3, 6, 9, 12, 15, 18, 21, 24, 27, 30, ..., 999

Sequence of multiple of 5: 5, 10, 15, 20, 25, 30, ..., 995 So, the sum is 3 + 5 + 6 + 9 + 10 + 12 + 15 + 18 + ... + 999.

Take note that we have to remove the duplicate of 15, 30, 45, ..., 990

### Method # 1: using Python

All the natural numbers below 1000 that are multiples of 3 or 5, are divisible by either 3 or 5. Hence, we need to add the numbers that are only divisible by 3 or 5. That is very easy in Python. Using the % operator will give use the remainder of the division.

For example, 4%2 = 0, 4%3 = 1. Therefore, in order to ad the number that is divisible by 3 or 5, we have to check for the remainder. We will only add the numbers that give zero for the remainder.
total = 0
for i in range(1000):
if not (i % 3 and i % 5):
total += i

### Method # 2: using Arithmetic sequence

To add all natural numbers from 1 to 10.

Notice that the sum will always gives 11, if we write it this way. 11 occurs 10 times, so, 11 x 10 = 110. However, that is the sum of 1 to 10 twice. So, we divide 110 by 2, we get the answer, which is 55.

The formula: Sum = n (a1 + a2) / 2 where n is the number of occurrence of the sequence from a1 to a2.

Back to our problem, the sum of 3, 6, 9, 12, 15, 18, 21, 24, 27, 30, ..., 999. Adding the first and last numbers gives us 3 + 999 = 1002. 1002 occurs 333 times, so 1002 * 333 = 333666. Divide it by 2, we get 166883.

Repeat the same procedure for the second sequence of 5s. Then, add the answers. However, as I mentioned previously, remember that we also have to remove the duplicates of 15, 30, 45, ..., 990.

The formula would be like this:

sum of multiple of 3 + sum of multiple of 5 - sum of multiple of 15
{"ft_lang_label":"__label__en","ft_lang_prob":0.90224296,"math_prob":0.99282295,"size":1789,"snap":"2021-43-2021-49","text_gpt3_token_len":601,"char_repetition_ratio":0.12661065,"word_repetition_ratio":0.077120826,"special_character_ratio":0.40637228,"punctuation_ratio":0.22649573,"nsfw_num_words":0,"has_unicode_error":false,"math_prob_llama3":0.99882424,"pos_list":[0],"im_url_duplicate_count":[null],"WARC_HEADER":"{\"WARC-Type\":\"response\",\"WARC-Date\":\"2021-10-16T08:34:53Z\",\"WARC-Record-ID\":\"<urn:uuid:68ae85a4-06b3-4032-ada7-b3ccec7f6bf1>\",\"Content-Length\":\"52000\",\"Content-Type\":\"application/http; msgtype=response\",\"WARC-Warcinfo-ID\":\"<urn:uuid:26ebf0b8-f0c3-43d1-80dc-f9c1d6f54447>\",\"WARC-Concurrent-To\":\"<urn:uuid:ce008441-4038-4231-843f-745bba69cbf8>\",\"WARC-IP-Address\":\"142.251.33.211\",\"WARC-Target-URI\":\"https://blog.rizauddin.com/search/label/addition\",\"WARC-Payload-Digest\":\"sha1:SIJLJ4ZR6KAQEG7S2JEY23N4TLXGBLBD\",\"WARC-Block-Digest\":\"sha1:HFSWOBGILL4FO7CUSYQNGOJRCPYQ4BJQ\",\"WARC-Identified-Payload-Type\":\"application/xhtml+xml\",\"warc_filename\":\"/cc_download/warc_2021/CC-MAIN-2021-43/CC-MAIN-2021-43_segments_1634323584554.98_warc_CC-MAIN-20211016074500-20211016104500-00562.warc.gz\"}"}