Results 1 to 3 of 3
Like Tree1Likes
  • 1 Post By jim829

Thread: Algorithms

  1. #1
    RedBlack51 is offline Member
    Join Date
    Sep 2014
    Posts
    1
    Rep Power
    0

    Angry Algorithms

    Can someone help me to write the algorithms of the following problems PLEASE!!

    1. Write an algorithm that asks the user for your birth date and the current date and displays how many days has passed since then (remember that April, June, September and November has 30 days, February has 29 on leap years, and the rest 31)

    2. Write an algorithm that asks the user a number (save it as N) and displays the N term of the Fibonnacci series (take it as 1, 1, 2, 3, 5 ...)

  2. #2
    jim829 is offline Senior Member
    Join Date
    Jan 2013
    Location
    Northern Virginia, United States
    Posts
    6,226
    Rep Power
    13

    Default Re: Algorithms

    Quote Originally Posted by RedBlack51 View Post
    Can someone help me to write the algorithms of the following problems PLEASE!!
    Only after you have tried yourself and then only to help you discover the problems when it doesn't work.

    Regards,
    Jim
    DarrylBurke likes this.
    The JavaTM Tutorials | SSCCE | Java Naming Conventions
    Poor planning on your part does not constitute an emergency on my part

  3. #3
    JosAH's Avatar
    JosAH is offline Moderator
    Join Date
    Sep 2008
    Location
    Voorschoten, the Netherlands
    Posts
    14,423
    Blog Entries
    7
    Rep Power
    27

    Default Re: Algorithms

    1) use Zeller's congruence method; the difference in days between two dates d1 and d2 is Z(d1)-Z(d2) where Z( ... ) is Zeller's congruence number.
    2) don't invoke F(n) for each value 'n' but use the recurrence relation F(n) = F(n-1)+F(n-2) (it' much cheaper).

    kind regards,

    Jos
    Build a wall around Donald Trump; I'll pay for it.

Similar Threads

  1. Need help with algorithms in looping
    By toomanypaces in forum New To Java
    Replies: 2
    Last Post: 01-27-2012, 10:03 AM
  2. Are these well written algorithms?
    By dharav in forum New To Java
    Replies: 3
    Last Post: 01-12-2012, 08:27 AM
  3. Compression Algorithms
    By kishan in forum Advanced Java
    Replies: 1
    Last Post: 09-21-2009, 09:13 AM
  4. genetic algorithms
    By nurfadhillah in forum Advanced Java
    Replies: 1
    Last Post: 10-19-2008, 04:13 PM
  5. Iterative Algorithms
    By Zosden in forum Algorithms
    Replies: 1
    Last Post: 07-05-2008, 06:29 AM

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •