MATH 160 Spring 2025
Introduction to Discrete Mathematics
Archived Class
Charles Cusack
Math & Stats
Hope College
Main
Schedule
Grading
Gradebook
Homework

Policies
Advice
College
    Policies

Notes
Programs
Tutorials

CSCI 125
CSCI 255
Others

Admin

Homework 10

Details

  1. (6 points) Given that there is a function pow(a,b) that computes ab, write a function int sumCubes(int n) that uses a for loop to compute 13+23+33+...+n3.
  2. (3 points) Write a function boolean isSet(int n,int b) that returns true if the bth bit of n is 1 and false otherwise. We order bits from right to left, so isSet(n,0) determines whether or not n is odd or even.
    It might help you to know that there is an operator a>>b that shifts a to the right by b bits, discarding the low order bits. For instance, 8 >> 2 gives you 2 and 15 >> 2 gives you 3.