Results 1 to 7 of 7

Help prime co prime

Threaded View

  1. #1
    Registered User
    Join Date
    11-20-2016
    Location
    TRINIDAD
    MS-Off Ver
    2013
    Posts
    3

    Help prime co prime

    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

    Function IsPrime(TestPrime As Long)
        Dim TestNum As Long
        Dim checkPrime As Boolean
        Dim TestLimit As Long
        If TestPrime Mod 2 = 0 Then Exit Function
        TestNum = 3
        TestLimit = TestPrime
        Do While TestLimit > TestNum
        If TestPrime Mod TestNum = 0 Then
        Exit Function
        End If
        TestLimit = TestPrime \ TestNum
        TestNum = TestNum + 2
        Loop
        checkPrime = True
        
        
         If checkPrime = True Then
         IsPrime = "prime"
         Else: IsPrime = "coprime"
         End If
        
         If TestPrime = 1 Then
         IsPrime = "neither"
         End If
         
         
      
        
    End Function
    Last edited by alansidman; 11-20-2016 at 07:35 PM. Reason: code tags

Thread Information

Users Browsing this Thread

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

Similar Threads

  1. Prime numbers macro
    By kaue in forum Excel Programming / VBA / Macros
    Replies: 8
    Last Post: 08-17-2020, 09:08 AM
  2. Hello from G-Prime
    By G-Prime in forum Hello..Introduce yourself
    Replies: 1
    Last Post: 07-27-2015, 08:50 AM
  3. prime number
    By abbccc in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 04-29-2013, 08:09 AM
  4. prime-factors
    By abbccc in forum Excel - New Users/Basics
    Replies: 4
    Last Post: 04-04-2013, 06:11 AM
  5. Prime numbers
    By Gearcutter in forum Excel Formulas & Functions
    Replies: 4
    Last Post: 03-08-2007, 09:03 AM
  6. [SOLVED] Prime Number just for fun
    By Paul Breslin in forum Excel Programming / VBA / Macros
    Replies: 7
    Last Post: 03-13-2006, 05:21 PM
  7. [SOLVED] Prime Numbers
    By Flyone in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 12-02-2005, 10:25 PM

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