Determine the remainder when 1234567...404142 is divided by 43.
Using mod 43 arithmetic all the way through, one can start with 1, and multiply by 10 or 100 as necessary, and add the new value (2 through 42) to obtain the desired answer:
after remainder
adding
2 12
3 37
4 30
5 4
6 3
7 37
8 34
9 5
10 37
11 13
12 22
13 20
14 36
15 3
16 15
17 12
18 14
19 0
20 20
21 0
22 22
23 30
24 14
25 6
26 24
27 19
28 36
29 17
30 10
31 42
32 18
33 27
34 25
35 41
36 8
37 20
38 17
39 19
40 5
41 25
42 5
The answer is 5.
DefDbl A-Z
Dim crlf$
Private Sub Form_Load()
ChDir "C:\Program Files (x86)\DevStudio\VB\projects\flooble"
Text1.Text = ""
crlf$ = Chr(13) + Chr(10)
Form1.Visible = True
DoEvents
remainder = 1
For i = 2 To 42
l = Len(LTrim(Str(i)))
remainder = (remainder * Int(10 ^ l + 0.5) + i) Mod 43
Text1.Text = Text1.Text & Str(i) & Str(remainder) & crlf
Next
End Sub
|
Posted by Charlie
on 2014-06-24 12:58:06 |