All about flooble | fun stuff | Get a free chatterbox | Free JavaScript | Avatars    
perplexus dot info

Home > General
Miles to Kilometers (Posted on 2016-02-26) Difficulty: 3 of 5
Define F(N) = Min ((N- floor(N)), (ceil(N) – N))
Given that:
M miles = N kilometers, where M is a positive integer ≤ 2016 and N is a real number.

(I) Determine the value of M that yields the smallest value of F(N)
(II) What is the value of M yielding the next smallest value of F(N))?

See The Solution Submitted by K Sengupta    
Rating: 5.0000 (1 votes)

Comments: ( Back to comment list | You must be logged in to post comments.)
Solution computer solution | Comment 2 of 3 |
  F(N)         M       N
0.0000640    1006  1619.0000640
0.0001280    2012  3238.0001280
0.0008960    1541  2479.9991040
0.0009600     535   860.9990400
0.0010240     471   758.0010240
0.0010880    1477  2377.0010880
0.0019200    1070  1721.9980800
0.0019840      64   102.9980160
0.0020480     942  1516.0020480
0.0021120    1948  3135.0021120
0.0028800    1605  2582.9971200
0.0029440     599   963.9970560
0.0030080     407   655.0030080
0.0030720    1413  2274.0030720
0.0039040    1134  1824.9960960
0.0039680     128   205.9960320
0.0040320     878  1413.0040320
0.0040960    1884  3032.0040960
0.0048640    1669  2685.9951360
0.0049280     663  1066.9950720
0.0049920     343   552.0049920
0.0050560    1349  2171.0050560
0.0058880    1198  1927.9941120
0.0059520     192   308.9940480
0.0060160     814  1310.0060160
0.0060800    1820  2929.0060800
0.0068480    1733  2788.9931520
0.0069120     727  1169.9930880
0.0069760     279   449.0069760
0.0070400    1285  2068.0070400
0.0078720    1262  2030.9921280

BTW: 1 mile is exactly 160934.4 cm or 1.609344 km, which explains all the zeroes in the seventh place after the decimal. So N is not just real; it's rational.

The above are the first several lines of the output from the following after being sorted:

DefDbl A-Z
Dim crlf$


Private Sub Form_Load()
 Form1.Visible = True
 
 Text1.Text = ""
 crlf = Chr$(13) + Chr$(10)
 
 Open "miles to kilometers.txt" For Output As #2
 
 For m = 1 To 2016
   If m Mod 10 = 0 Then Text1.Text = Text1.Text & m
   DoEvents
   n = m * 5280 * 12 * 2.54 / 100000
   nround = Int(n + 0.5)
   Print #2, mform(Abs(n - nround), "0.0000000") & "  ";
   Print #2, mform(m, "#####0") & mform(n, "#####0.0000000")
 Next

 Close #2
 
 Text1.Text = Text1.Text & crlf & " done"
  
End Sub

Function mform$(x, t$)
  a$ = Format$(x, t$)
  If Len(a$) < Len(t$) Then a$ = Space$(Len(t$) - Len(a$)) & a$
  mform$ = a$
End Function

Edited on February 26, 2016, 10:03 am
  Posted by Charlie on 2016-02-26 10:03:15

Please log in:
Login:
Password:
Remember me:
Sign up! | Forgot password


Search:
Search body:
Forums (0)
Newest Problems
Random Problem
FAQ | About This Site
Site Statistics
New Comments (8)
Unsolved Problems
Top Rated Problems
This month's top
Most Commented On

Chatterbox:
Copyright © 2002 - 2024 by Animus Pactum Consulting. All rights reserved. Privacy Information