+ Reply to Thread
Results 1 to 19 of 19

Task the predetermined number N is the degree of the number a

  1. #1
    Registered User
    Join Date
    03-21-2020
    Location
    Moscow, Russia
    MS-Off Ver
    16.35
    Posts
    5

    Task the predetermined number N is the degree of the number a

    Hi all,
    I have a problem with solving this problem since the main idea is to solve it without any branches and loops. I can’t solve it. I will be very grateful for any help.
    I will repeat the task again completely: The predetermined number N is the degree of the number a (the exponent may be in the range from 0 to 4).

  2. #2
    Forum Guru
    Join Date
    04-23-2012
    Location
    New Jersey, USA
    MS-Off Ver
    Excel 365
    Posts
    2,408

    Re: Task the predetermined number N is the degree of the number a

    I am sorry, but what you are asking is not completely clear to me. Can you provide a few real number examples of the values you have, how they should be used and what would the answer be for each of your examples?

  3. #3
    Registered User
    Join Date
    03-21-2020
    Location
    Moscow, Russia
    MS-Off Ver
    16.35
    Posts
    5

    Re: Task the predetermined number N is the degree of the number a

    Sorry for my English, I will try to explain
    for example, the number N=625 is a degree of number a=5
    So I enter N=625 and the enter a=5, answer must be true
    Last edited by Venian; 03-21-2020 at 03:14 PM.

  4. #4
    Forum Guru
    Join Date
    04-23-2012
    Location
    New Jersey, USA
    MS-Off Ver
    Excel 365
    Posts
    2,408

    Re: Task the predetermined number N is the degree of the number a

    What you want for an answer is not entirely clear, but let me take a guess...

    Assuming 625 is in cell A1 and 5 is in cell B1, does this formula give you the result you want...

    =LOG(A1,B1)

    or does this one...

    =MOD(LOG(A1,B1),1)=0
    Last edited by Rick Rothstein; 03-21-2020 at 03:17 PM.

  5. #5
    Registered User
    Join Date
    03-21-2020
    Location
    Moscow, Russia
    MS-Off Ver
    16.35
    Posts
    5

    Re: Task the predetermined number N is the degree of the number a

    This is C++ code, I need something similar only without cycles and for any numbers

    int main()
    {
    int n,a;
    bool r=true;
    cout<<"Enter n"<< '\n';
    cin>>n;
    while(n!=1) //;
    {
    a=n%5;
    if(a!=0)
    {
    r=false;
    break;
    }
    n/=5;
    }
    if(r)
    cout << "yes"<<'\n';
    else
    cout<<"no"<<'\n';
    return 0;
    }

  6. #6
    Forum Guru
    Join Date
    04-23-2012
    Location
    New Jersey, USA
    MS-Off Ver
    Excel 365
    Posts
    2,408

    Re: Task the predetermined number N is the degree of the number a

    I cannot read C++ code. I am guessing you want a macro. Fine. And it looks like you want the macro to ask you for a number (625 for example). Once you put 625 into the macro, what do you want the macro to do? You have to tell us what you expect the macro to do next as we have no idea what your expectations are. Will it ask for base number (5 from your example)... your code does not appear to do that, rather it looks like the 5 is hard-coded in... and return the power for it (5 raised to the 4th power is 625)? Or do you want the macro to tell you if it is a perfect power (that is, there is a whole number that 5 can be raised to in order to get 625 as a value)? To repeat, we do not know what values you want to test, how the macro is to get them or exactly what answer you are expecting the macro to give you... you have to explain these things in detail to us... we will probably not be able to guess what is in your mind for them.

  7. #7
    Registered User
    Join Date
    03-21-2020
    Location
    Moscow, Russia
    MS-Off Ver
    16.35
    Posts
    5

    Re: Task the predetermined number N is the degree of the number a

    So lets forgot about c++ code, its was not perfect example of this task... Sooo I expect that's I enter any number "N" and "a" Example: N=16 a=2 Result: True, Next Example: N=10 a=3 Result: false, I expect this, but I have problem with coding this task, because on assignment I can’t use "while" "for" and etc. I can write the code using "while" "for" but without them I have problems, so I ask for help with the code

  8. #8
    Forum Guru
    Join Date
    04-23-2012
    Location
    New Jersey, USA
    MS-Off Ver
    Excel 365
    Posts
    2,408

    Re: Task the predetermined number N is the degree of the number a

    It sounds like this is a homework assignment so I am not sure if the code I wrote would be acceptable, but this will do what you want...
    Please Login or Register  to view this content.

  9. #9
    Forum Expert
    Join Date
    11-24-2013
    Location
    Paris, France
    MS-Off Ver
    Excel 2003 / 2010
    Posts
    9,831

    Arrow Re: Task the predetermined number N is the degree of the number a


    Hi,

    or just MsgBox (Num Mod Base = 0)

  10. #10
    Forum Guru
    Join Date
    04-23-2012
    Location
    New Jersey, USA
    MS-Off Ver
    Excel 365
    Posts
    2,408

    Re: Task the predetermined number N is the degree of the number a

    @Marc L,

    I don't think that code line is sufficiently robust. If I understand the OP's question correctly (and there is no guarantee I have), I think he wants to know if the base can be raised to a whole number power such that it equals the number. Your test would report True if Num equals 10 and Base equals 2 but 2 cannot be raised to any whole number power to equal 10.

  11. #11
    Forum Expert
    Join Date
    11-24-2013
    Location
    Paris, France
    MS-Off Ver
    Excel 2003 / 2010
    Posts
    9,831

    Exclamation Re: Task the predetermined number N is the degree of the number a


    Rick, yes I knew as my codeline returns exactly the same result as your If … End If block !
    You can check yourself if you answer 10 & 2 to your input boxes !
    So now you know your code is wrong; a good way is to check if the Power result is not decimal …

  12. #12
    Forum Expert
    Join Date
    11-24-2013
    Location
    Paris, France
    MS-Off Ver
    Excel 2003 / 2010
    Posts
    9,831

    Cool Give it a try …


    Checking via a function :

    PHP Code: 
    Function IsFixPower(N&, B&) As Boolean
             P
    # = Log(N) / Log(B)
             
    IsFixPower Fix(P)
    End Function 
    Do you like it ? So thanks to click on bottom left star icon « Add Reputation » !

  13. #13
    Forum Guru
    Join Date
    04-23-2012
    Location
    New Jersey, USA
    MS-Off Ver
    Excel 365
    Posts
    2,408

    Re: Task the predetermined number N is the degree of the number a

    @Me,

    Arrgh!!! I calculated the Power and then never used it!!!!!

    Here is the code I should have posted...
    Please Login or Register  to view this content.
    Last edited by Rick Rothstein; 03-21-2020 at 10:15 PM.

  14. #14
    Forum Expert
    Join Date
    11-24-2013
    Location
    Paris, France
    MS-Off Ver
    Excel 2003 / 2010
    Posts
    9,831

    Thumbs up Re: Task the predetermined number N is the degree of the number a


    I like your Like for the Power, as the great Albert may have said : that's the power of like !

  15. #15
    Forum Guru
    Join Date
    04-23-2012
    Location
    New Jersey, USA
    MS-Off Ver
    Excel 365
    Posts
    2,408

    Re: Task the predetermined number N is the degree of the number a

    Quote Originally Posted by Marc L View Post

    I like your Like for the Power...
    Using it in your function to produce a one-liner...
    Please Login or Register  to view this content.

  16. #16
    Forum Expert
    Join Date
    11-24-2013
    Location
    Paris, France
    MS-Off Ver
    Excel 2003 / 2010
    Posts
    9,831

    Exclamation Re: Task the predetermined number N is the degree of the number a


    Sorry but I forgot to notice it can not work on my side 'cause of the decimal separator not a point but a comma,
    the reason why I prefer my original function which works whatever the decimal separator is …

  17. #17
    Forum Guru
    Join Date
    04-23-2012
    Location
    New Jersey, USA
    MS-Off Ver
    Excel 365
    Posts
    2,408

    Re: Task the predetermined number N is the degree of the number a

    Does this work...
    Please Login or Register  to view this content.
    I think it should, but if not, what about this...
    Please Login or Register  to view this content.
    Or, more than likely, this...
    Please Login or Register  to view this content.

  18. #18
    Registered User
    Join Date
    03-21-2020
    Location
    Moscow, Russia
    MS-Off Ver
    16.35
    Posts
    5

    Re: Task the predetermined number N is the degree of the number a

    Thanks to everyone for helping, I think the problem is solved

  19. #19
    Forum Expert
    Join Date
    11-24-2013
    Location
    Paris, France
    MS-Off Ver
    Excel 2003 / 2010
    Posts
    9,831

    Arrow Re: Task the predetermined number N is the degree of the number a


    Thanks for the rep' !

    Quote Originally Posted by Rick Rothstein View Post
    Does this work...
    I thought for #2 & 3 but not for the first - my favorite - as I should, it was late on my side … All work.

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Similar Threads

  1. Divide by number a predetermined number of row above
    By ey_up in forum Excel Formulas & Functions
    Replies: 3
    Last Post: 03-21-2020, 04:48 AM
  2. Custom number as angle degree
    By Kiwi den in forum Excel General
    Replies: 2
    Last Post: 12-12-2019, 11:18 PM
  3. Replies: 1
    Last Post: 12-20-2018, 10:07 AM
  4. Replies: 2
    Last Post: 06-05-2018, 12:51 PM
  5. Replies: 8
    Last Post: 12-18-2016, 12:43 PM
  6. Replies: 4
    Last Post: 12-18-2016, 12:22 PM
  7. Replies: 3
    Last Post: 03-27-2005, 08:07 AM

Tags for this Thread

Bookmarks

Posting Permissions

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

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1