How to pick the current date and find whether it is prime number or not

Hello All,
I need support on the below scenario.
Need to get the current date and then need to add the date and month then need to find whether it is belongs to prime number or not.

1 Like

///Will provide current date
CurrentDate=System.DateTime.now.ToShortDateString

///Will provide string array
datemonth=CurrentDate.split(“/”,StringSplitOptions.None)

///Will provide sum of day and month
datemonthadd=Convert.toint32(datemonth(0))+Convert.toint32(datemonth(1))

Now you can use the if activity to check for prime number

You can get the sum of day and month using the below code.

SumOfDayAndMonth = DateTime.Now.Day + DateTime.Now.Month

To check if the result is a sum you need to use an invoke code activity with the below code. You need to modify the below code to suit invoke code activity.

Public Shared Function IsPrime(number As Integer) As Boolean
	If number <= 1 Then
		Return False
	End If
	If number = 2 Then
		Return True
	End If
	If number Mod 2 = 0 Then
		Return False
	End If

	Dim boundary As Integer = CType(Math.Floor(Math.Sqrt(number)), Integer)

	Dim i As Integer = 3
	While i <= boundary
		If number Mod i = 0 Then
			Return False
		End If
		i += 2
	End While

	Return True
End Function