How to resolve the algorithm Find the last Sunday of each month step by step in the Oforth programming language
Published on 12 May 2024 09:40 PM
How to resolve the algorithm Find the last Sunday of each month step by step in the Oforth programming language
Table of Contents
Problem Statement
Write a program or a script that returns the last Sundays of each month of a given year. The year may be given through any simple input method in your language (command line, std in, etc). Example of an expected output:
Let's start with the solution:
Step by Step solution about How to resolve the algorithm Find the last Sunday of each month step by step in the Oforth programming language
Source code in the oforth programming language
import: date
: lastSunday(y)
| m |
Date.JANUARY Date.DECEMBER for: m [
Date newDate(y, m, Date.DaysInMonth(y, m))
while(dup dayOfWeek Date.SUNDAY <>) [ addDays(-1) ] println
] ;
You may also check:How to resolve the algorithm Roots of unity step by step in the МК-61/52 programming language
You may also check:How to resolve the algorithm Stern-Brocot sequence step by step in the REXX programming language
You may also check:How to resolve the algorithm Pseudo-random numbers/Middle-square method step by step in the AWK programming language
You may also check:How to resolve the algorithm Random number generator (included) step by step in the Lua programming language
You may also check:How to resolve the algorithm Van Eck sequence step by step in the Ada programming language