Thread: Struggling with c++ math related issue

  1. #1
    Registered User
    Join Date
    Nov 2022
    Posts
    3

    Struggling with c++ math related issue

    Hey there everybody,
    Hope you are well ! First time posting here as i am somewhat new to the programming world. I am currently using C++ and wish to write a code for the following issue. Please study the below and let me know of your thoughts and how you would approach this. Many thanks in advance for having a look.
    Kindest Regards

    I wish to write down a code which would assist me in finding all the 8 digit numbers that when their each individual digit gets raised on a power (any power) and then summed the initial number would occur. The individual digits would all be raised on the same value power.

    Looking forward to your responses on this.

  2. #2
    and the hat of int overfl Salem's Avatar
    Join Date
    Aug 2001
    Location
    The edge of the known universe
    Posts
    39,659
    So is this a maths question or a programming question?

    For example,
    Code:
    int target_number = 12345678;
    int digits[8];
    Can you code something to get to
    digits[0] = 1
    digits[1] = 2
    etc?
    If you dance barefoot on the broken glass of undefined behaviour, you've got to expect the occasional cut.
    If at first you don't succeed, try writing your phone number on the exam paper.

  3. #3
    Registered User
    Join Date
    Nov 2022
    Posts
    3
    Well actually its a math related, programming issue.

  4. #4
    and the hat of int overfl Salem's Avatar
    Join Date
    Aug 2001
    Location
    The edge of the known universe
    Posts
    39,659
    So can you manage the first step or not?

    You're not going to get a complete answer, so you're going to have to meet us half way.

    I've suggested a first step, let's see how far you can get by yourself before you get stuck.
    Then we can answer specific questions.

    > Well actually its a math related, programming issue.
    Do you know how to solve the problem on paper?
    No - it's a maths problem.
    Yes - it's a programming problem.

    There is no point showing you code if you've no idea how to solve it on paper.
    If you dance barefoot on the broken glass of undefined behaviour, you've got to expect the occasional cut.
    If at first you don't succeed, try writing your phone number on the exam paper.

  5. #5
    Registered User
    Join Date
    Nov 2022
    Posts
    3
    To be honest i actually had it solved on paper way before i posted this hehe. I am now close to finding a way on C++ too. If i require any extra assistance i shall inform although i think i got this on my own.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Struggling to find the related docs for off_t/off64_t
    By awsdert in forum C Programming
    Replies: 1
    Last Post: 07-24-2022, 07:18 AM
  2. struggling with function issue
    By Mungo in forum C Programming
    Replies: 5
    Last Post: 12-26-2019, 04:23 AM
  3. Math related calculation error?
    By jae5086 in forum C++ Programming
    Replies: 3
    Last Post: 10-13-2010, 01:48 PM
  4. Help with first c++ program (math-related)
    By necrovamp in forum C++ Programming
    Replies: 4
    Last Post: 09-23-2010, 12:33 PM
  5. Math related Programming Books
    By curlious in forum C++ Programming
    Replies: 7
    Last Post: 07-08-2003, 11:17 PM

Tags for this Thread