Post-AP Problems                                     Check your Work Here


Students cheating will receive a 0 for the marking period. People who help other people will get a 0.
Don't put someone else's grade at risk. Don't cheat.



  1. Find the sum of all the factors of 1024.




  2. If we add the fractions 1/2 + 1/3 + 1/4 + 1/5 ... what is the denominator of the fraction that makes our sum go over 4?




  3. What three numbers when multiplied together equals 9367 and when added together equals 65. When you enter your answer enter the numbers together in order from smallest to biggest (if your answer was 7, 23 and 19 you would enter 71923).




  4. If we list all the numbers below 10 that are multiples of 3 or 5, we get 3, 5, 6 and 9. The sum of these multiples is 23.

    Find the sum of all the multiples of 3 or 5 up to and including 1000.




  5. Find the sum of all the prime numbers from 1 to 1000.




  6. Write a program that will tell you how many years the $20000 you have in the bank will take to double if it gets 5% interest a year.




  7. Write a program that will print the sum of all of its prime factors of 3274. You probably want to write an isPrime method to help.

    public static boolean isPrime(int n)




  8. The prime factors of 13195 are 5, 7, 13 and 29. The largest prime factor is 29.

    What is the largest prime factor of the number 1263528651 ? (For this problem you are going to have to use long instead of int. They are the same, except long can hold bigger numbers. You will also have to tell the computer that numbers are long or you will get an over flow error
    long n = 1263528651L;

    Putting the L on the end of the long int let the computer know it was a long int




  9. Each new term in the Fibonacci sequence is generated by adding the previous two terms. By starting with 1 and 2, the first 10 terms will be:

    1, 2, 3, 5, 8, 13, 21, 34, 55, 89, ...

    What is the 50th number in the sequence?

    You will have to use long int for this program.




  10. A Pythagorean triplet is a set of three natural numbers, a<b<c, for which, a + b = c

    For example, 3 + 4 = 9 + 16 = 25 = 5.

    There exists exactly one Pythagorean triplet for which a + b + c = 1000. To check enter the numbers from smallest to largest with no spaces in between.


  11. Write a program that will tell you what the sum of all the prime numbers that end in 7 between 1 and 25000.




  12. Enter a number and have the computer give you the sum of the digits. Test your program the number is 8349457235.




  13. A perfect number is a number in which each digit of the number is also a factor of the number. If it has a zero it is not a perfect number. Write a method that will tell you the first 3 perfect numbers > 1000. Enter the numbers without spaces to check in ascending order.




  14. A really perfect number is one in which of the digits are factors of the number and the sum of the digits is also a factor of the number. If it contains a 0 it is not a perfect number. Print the first 3 really perfect numbers > 50000. Enter the three numbers in ascending order.

    For example, if your answer was 200, 300 and 500.

    You would enter 200300500




  15. 2520 is the smallest number that can be divided by each of the numbers from 1 to 10 without any remainder.

    What is the smallest number that is evenly divisible by all of the numbers from 1 to 20?


  16. If you flip 4 coins 100000 times, What percentage of the time will you get 4 heads. Simulate the flipping of the coins with random numbers. Only type in the closest whole number for the percentage. (if it is 23.678% only type in 24)




  17. The sum of the squares of the first ten natural numbers is, 1 + 2 + ... + 10 = 385

    The square of the sum of the first ten natural numbers is,

    (1 + 2 + ... + 10) = 55 = 3025

    Hence the difference between the sum of the squares of the first ten numbers and the square of the sum is 3025 − 385 = 2640.

    Find the difference between the sum of the squares of the first one hundred numbers and the square of the sum.




  18. The following iterative sequence is defined for the set of positive integers:

    n → n/2 (n is even)
    n → 3n + 1 (n is odd)


    Using the rule above and starting with 13, we generate the following sequence:

    13 → 40 → 20 → 10 → 5 → 16 → 8 → 4 → 2 → 1

    It can be seen that this sequence (starting at 13 and finishing at 1) contains 10 terms. Although it has not been proved yet (Collatz Problem), it is thought that all starting numbers finish at 1.

    Have a method receive a 23 and then print out the sum of the numbers in the chain up to and including 1.

    NOTE: Once the chain starts the terms are allowed to go above one million.




  19. If you fill an array with 10 unique numbers between 1 and 100 and fill another array with 10 unique numbers between 1 and 100 what percentage of the time will you get at least one number in common (Round your percent to the nearest whole number). Run your simulation 100,000 times to get the answer.



The programs below cannot be checked on line- you should be able to see if they work by checking the output


  1. Write a method that will receive an integer and then print out the digits one at a time (on seperate lines, in any order).




  2. Write a method that will receive a number and will return a new number that is the reverse of the number entered. For example if you enter 4567 the new number returned will be 7654.




  3. A baby sitter charges $1.50 per hour until 9:00 pm (while the kids are still up), $1.00 per hour between 9:00 pm and midnight, and $1.25 per hour after midnight (since late night baby sitting interferes with morning classes).

    Write a method that takes as arguments the sitter's starting time in hours and minutes and the ending time in hours and minutes and then computes the sitter's fee. Pay the sitter for parts of an hour (so that if they work 22 minutes they get 22/60 of that hour's pay). Assume all times are between 6:00 pm and 6:00 am.




  4. Write a method that will receive a numerator and a denominator and then print out the fraction reduced to lowest terms.




  5. Write a method that will receive a word and return a new String that is the reverse of the first. For example if you sent it Mike it would send back ekiM




    public String reverse(String s)

  6. Write a method that will receive a word and then return a new word that is the same as the first except all vowels are removed.






    public String removeVowels(String s)

  7. Write a method that will receive a sentence and then return a new string with dashes in place of all the consonants. For example if the method received hello tom it would return -eo o-






  8. Write a program that will ask 10 random multiplication problems (with numbers between 1 and 20). The program will let the person using it answer each question and tell them whether they were right or wrong, and will then tell them what their score was on the test.

    public void askQuestions()




  9. Write a program that will let you enter a numerator , denominator and then another numerator and denominator and will then tell you the sum of the two fractions (reduced and in proper form)

    public void addFractions(int n1, int d1, int n2, int d2)

    For example
    Enter numerator 4
    Enter denominator 5
    Enter a numerator 2
    Enter a denominator 3
    Answer is 1 7/15





  10. Write a method that will receive a paragraph and will then return the paragraph with every other word removed.

    public String removeWords(String para)





  11. Write a program that will let you enter 10 names into an ArrayList and will then print out the names in a random order (with no repeats)

    public ArrayList enter()

    public void printRandom(ArrayList ar)




  12. Write a program that will let you fill an ArrayList with 100 random numbers - then delete all the odd numbers - print out the list to check your work.




  13. Same as above except use an array - make sure that you have a count in your class - when you delete a number make sure the count is changed. (It won't change automatically like it does with an ArrayList - you can leave all the other spots as 0)

    For example if the array held 3 7 8 12 34 67 and count was 6

    When you are done - array will hold 8 12 34 0 0 0 and count will be 3




  14. Write a program that will print out 25 random multiplication problems (1 at a time). It will tell the user whether they answered correctly or not. It will give them a score at the end of the game.




  15. Write a number quessing game. The computer will pick a random number between 1 and 1000. It will then let you guess. It will tell you "Too High" or "Too Low" until you guess it. It will then tell you how many guesses you took.




  16. Write a program that will scramble a word that it receives. It will scramble it by randomly exchanging 2 of the letters in the word. Do the exchanges the length of the word times.




  17. Using the strategy developed above - scramble a paragraph by scrambling each of the words. You can set a String equal to a paragraph and then send it up to method to be scrambled.
    For example, if you send it, " Mary had a litle lamb" it would send back "yMar dah a ttlile amlb"




  18. Same as above but scramble the words and the order of the words so "Mary had a little lamb" could return "Almb a raMy dah tltlie"




  19. Write a program that will print out all the prime numbers between 10 and 10,000 that begin and end with the same number.
    Ex.
    11
    131
    373