Ask Me Help Desk

Ask Me Help Desk (https://www.askmehelpdesk.com/forum.php)
-   Mathematics (https://www.askmehelpdesk.com/forumdisplay.php?f=199)
-   -   Closed Form Problem (https://www.askmehelpdesk.com/showthread.php?t=562107)

  • Mar 14, 2011, 07:31 AM
    joegonota
    Closed Form Problem
    Hi all,

    Please have a look of following question


    Q:

    Find the exact number of times, in terms of the natural number n that s is executed in the following algorithm


    I:=0

    while I<n do

    s;

    I:i+3;

    od


    Please give me some advise to solve this question... thanks a lot
  • Mar 14, 2011, 11:30 PM
    Unknown008

    I'm having trouble understanding your problem...

    I'm particularly not familiar with the functions 'do', 's' and 'od' do...
  • Mar 15, 2011, 10:30 AM
    jcaron2
    The variable i starts at 0, then gets incremented by 3 each time through the loop (assuming I'm reading the syntax correctly; I'm not familiar with whatever language that is). The loop ends when i is no longer less than n. That means the loop runs approximately n/3 times.

    If you want to get really specific, it actually runs (floor(n/3) + 1) times, where the "floor" function means that you round down to the nearest integer.

  • All times are GMT -7. The time now is 08:49 AM.