Advertisement
Guest User

Untitled

a guest
Jul 25th, 2016
60
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.63 KB | None | 0 0
  1. [COMPUTER PROGRAMMING PROBLEM SET 6]
  2. As with all problem sets, this is available online at gist.github.com/youlianBEAM under the name "hw6.txt"
  3. ================
  4. Mandatory part
  5. ================
  6.  
  7. We're going to finish the functions exercise that we started doing in class.
  8.  
  9. 0) Log in to your CycleShell account and create a new project, titled "HW6 - FunctionsExercise"
  10.  
  11. 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:
  12.  
  13. require('cycle-shell')(main)
  14.  
  15. function main (input) {
  16. return input
  17. }
  18.  
  19. function DoubleAndAdd(number) {
  20. return number
  21. }
  22.  
  23. function Halve(number){
  24. return number
  25. }
  26.  
  27. 2) Fill in the code for the DoubleAndAdd function, which takes a number as input and returns twice that number plus 1 as output.
  28.  
  29. 3) Once you've defined the function, call it from Main and return that value.
  30. Sample Input 1: 3 Sample Input 2: 12
  31. Sample Output 1: 7 Sample Output 2: 25
  32.  
  33. SAVE YOUR WORK ONCE THIS IS DONE.
  34.  
  35. 4) Fill in the code for the HalveNumber function, which takes a number as input and returns half of that number.
  36.  
  37. 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.
  38. Sample Input 1: 3 Sample Input 2: 12
  39. Sample Input 1: 7 Sample Output 2: 6
  40.  
  41. SAVE YOUR WORK ONCE THIS IS DONE.
  42.  
  43. 6) Send whatever progress you've made to youlianBEAM@gmail.com
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement