Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- [COMPUTER PROGRAMMING PROBLEM SET 6]
- As with all problem sets, this is available online at gist.github.com/youlianBEAM under the name "hw6.txt"
- ================
- Mandatory part
- ================
- We're going to finish the functions exercise that we started doing in class.
- 0) Log in to your CycleShell account and create a new project, titled "HW6 - FunctionsExercise"
- 1) Go to gist.github.com/youlianBEAM. Find the "index.js" file titled "FunctionsExercise", and copy the code from there into your new project. If you can't find it, the code is as follows:
- require('cycle-shell')(main)
- function main (input) {
- return input
- }
- function DoubleAndAdd(number) {
- return number
- }
- function Halve(number){
- return number
- }
- 2) Fill in the code for the DoubleAndAdd function, which takes a number as input and returns twice that number plus 1 as output.
- 3) Once you've defined the function, call it from Main and return that value.
- Sample Input 1: 3 Sample Input 2: 12
- Sample Output 1: 7 Sample Output 2: 25
- SAVE YOUR WORK ONCE THIS IS DONE.
- 4) Fill in the code for the HalveNumber function, which takes a number as input and returns half of that number.
- 5) Change your main function so that it applies the halving function to numbers that are divisible by 2, and applies the 2n+1 function to numbers that are not divisible by 2.
- Sample Input 1: 3 Sample Input 2: 12
- Sample Input 1: 7 Sample Output 2: 6
- SAVE YOUR WORK ONCE THIS IS DONE.
- 6) Send whatever progress you've made to youlianBEAM@gmail.com
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement