Assignment 1
Write a prolog program to read a number from the keyboard. If the number is less than 10, print only the odd numbers less than 10 to the screen. If the number is greater or equal to 10, all the odd numbers from 1 to 10 are printed together with the even numbers thereafter. Below are examples of a number is read (N) and the printed output values:
• N=1 : 1
• N=2 : 1
• N=3 : 1 3
• N=4 : 1 3
• N=8 : 1 3 5 7
• N=9 : 1 3 5 7 9
• N=10: 1 3 5 7 9 10
• N=11: 1 3 5 7 9 10
• N=12: 1 3 5 7 9 10 12
• N=15: 1 3 5 7 9 10 12 14
• N=0 : no output
This program requires you to use programming logic instructions that include recursive calls and if and else statements.
It is an individual project. The program should be tested in the online SWISH before submitting for grading. Write appropriate comments to indicate the flow of your program. After testing, copy the program to a word document. This word document is then submitted to the dropbox in the CN. Write your name and student ID number in your word document.
The program must be submitted before 11: 59 pm, 24/10/2020. Late submission is not allowed. If you do need assistance you can consult me during my consultation hours via Zoom.