Search
 
SCRIPT & CODE EXAMPLE
 

SWIFT

prime number swift


# Prime number:

n = int(input("Please enter your input number: "))
if n>1:
    for i in range(2,n):
        if n%i == 0:
            print("%d is a Not Prime."%n)
            break
    else:
        print("%d is a Prime."%n)
else:
    print("%d is a Not Prime."%n)
    
# Use to Definition Function:

'''
def Prime_number_chcek(n):
    if n>1:
        for i in range(2,n):
            if n%i == 0:
                return ("%d is a Not Prime."%n)
        return ("%d is a Prime."%n)
    return ("%d is a Not Prime."%n)

# Main Driver:
if __name__=="__main__":
    n = int(input("Enter your input number: "))
    print(Prime_number_chcek(n))
'''
Comment

Prime number or not program in swift basic programs

var value=0var n = 10var i = 2for i in 2 ... n-1{    if(n%i==0)    {        value = 1;        break;    }}if(value==1){    print("(n)" + " not prime")}else{    print("(n)" + "  prime")}
Comment

PREVIOUS NEXT
Code Example
Swift :: swift programmatically set font 
Swift :: swift constructor 
Swift :: swiftui crop image 
Swift :: convert uiimage to swiftui image 
Swift :: Swift Switch Statement with Range 
Swift :: how to Not bool bindng swiftui 
Swift :: Nested if...else Statement 
Swift :: hstack spacing swiftui 
Swift :: swift extension Array where element 
Swift :: Swift Class and Objects 
Swift :: swiftui hidden 
Swift :: swift create custom button with icon programmatically 
Swift :: swift switch statement 
Swift :: how to send a file from file manager in mail swift 
Swift :: swift array in chunks 
Swift :: swift disable modal dismiss swift 
Swift :: swift ns_enum generic name 
Swift :: swift 5 progress bar height 
Swift :: swift api call with certificate 
Swift :: appendBytes: Lengt: SWIFT 
Swift :: Swift Arithmetic Operators 
Swift :: Swift guard with multiple conditions 
Swift :: Assign values to enum variables Swift 
Swift :: swift split an array into chunks 
Swift :: Swift print() with terminator 
Swift :: swift await async 
Ruby :: how to rename a table in ruby 
Ruby :: ruby key exists 
Ruby :: rails link_to class 
Ruby :: add timezone in rails 
ADD CONTENT
Topic
Content
Source link
Name
7+3 =