help im trying to output prime and coprime AND NEITHER DEPENDING ON THE NUMBERand its not working
i have been trying for hours and its not working
swift help would be appreciated
![]()
Please Login or Register to view this content.
help im trying to output prime and coprime AND NEITHER DEPENDING ON THE NUMBERand its not working
i have been trying for hours and its not working
swift help would be appreciated
![]()
Please Login or Register to view this content.
Last edited by alansidman; 11-20-2016 at 07:35 PM. Reason: code tags
Code Tags Added
Your post does not comply with Rule 3 of our Forum RULES. Use code tags around code.
Posting code between [CODE]Please [url=https://www.excelforum.com/login.php]Login or Register [/url] to view this content.[/CODE] tags makes your code much easier to read and copy for testing, it also maintains VBA formatting.
Highlight your code and click the # icon at the top of your post window. More information about these and other tags can be found at http://www.excelforum.com/forum-rule...rum-rules.html
(I have added them for you today. Please take a few minutes to read all Forum Rules and comply in the future.)
Alan עַם יִשְׂרָאֵל חַי
Change an Ugly Report with Power Query
Database Normalization
Complete Guide to Power Query
Man's Mind Stretched to New Dimensions Never Returns to Its Original Form
One way:
A B C 1 264,627,858,537,807 3B1: =isprime(A1, TRUE) 2 250,522,486,845,971 6719759 3 336,502,419,415,881 3 4 213,751,729,707,615 5 5 215,771,119,714,057 164513 6 384,515,184,772,903 17 7 383,451,182,203,411 7 8 234,532,507,205,987 TRUE 9 328,100,503,187,517 3 10 200,768,597,700,379 17
![]()
Please Login or Register to view this content.
Entia non sunt multiplicanda sine necessitate
interesting but can u tell me whats wrong with my code?
I don't know how it's supposed to work. "co-prime" is a property of two numbers, not 1.
"Doesn't work" can be a rather unhelpful way to describe a problem. Can you explain what you mean by "doesn't work"? When I copy your function into a blank worksheet and use it, it seems to "work" (meaning that it runs without syntax or run-time errors) just fine. It returns 0 (the value written to Excel for empy variants) for non-prime numbers and "prime" for prime numbers -- as it has been instructed to do. I would guess that these are not your expected results. What are your expected results?
As a debugging step, I added a few Stop statements to your UDF.I recommend that you setup your spreadsheet and see what is happening inside of the code. Identify where the code is doing something you don't expect. Then you will be in a better position to change the code to do what you want. If you need help making the edits, tell us where it is doing something unexpected or unwanted, explain what you want it to do instead, and we should be able to help you edit the code.![]()
Please Login or Register to view this content.
I also note, like shg, that there is nothing in the code for computing coprimes. The code as written will only identify prime or not-prime numbers. I note, from the Wikipedia page for coprimes (https://en.wikipedia.org/wiki/Coprime ) that there may be simpler algorithms based on some of the properties of coprime numbers.
One algorithm might use the built in GCD() function https://support.office.com/en-us/art...c-ddfc21b5073a
Another might use the built in LCM() function. https://support.office.com/en-us/art...c-06ede5563c94
Originally Posted by shg
There are currently 1 users browsing this thread. (0 members and 1 guests)
Bookmarks