Advertisement
biswasrohit20

f# Ex 9

May 20th, 2021
265
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.59 KB | None | 0 0
  1. // Exercise 9 – General (… continued from previous – General)
  2. // Queation 5
  3. // Year of
  4.  
  5. open System
  6.  
  7. let yearOf(x:int):int=
  8. let (year400:int) = (x - 1) / (400 * 365 + 97)
  9. let y = (x - 1) % (400 * 365 + 97)
  10. let (year100:int) = y / (100 * 365 + 24)
  11. let z = y % (100 * 365 + 24)
  12. let (year4:int) = z / (4*365 + 1)
  13. let w = z % (4*365 + 1)
  14. let (year1:int) = w / 365
  15.  
  16. let mutable year = year400*400 + year100*100 + year4*4 + year1 + 1
  17. if year = 4 then year <- year - 1
  18.  
  19. year
  20.  
  21. printfn "%i" (yearOf(654415))
  22. Console.ReadKey() |> ignore
  23.  
  24.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement