-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathrisan2.R
More file actions
53 lines (50 loc) · 743 Bytes
/
risan2.R
File metadata and controls
53 lines (50 loc) · 743 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
library(pracma)
#if the result shows True, the proposition is True. Or the proposition is False
k = sample(1:1000,100) #choice 100 random n in 1:1000
f1 = function(n)
{
if(n%%2 == 0)
{
if((n+1)%%5 == 0)
{
return(1)
}
else return(2)
}
else return (0)
}
f2 = function(n)
{
if((n+1)%%5 == 0)
{
if(isprime(n+2) == 1)
return(1)
else return(2)
}
else return(0)
}
f_s = function(n)
{
q = f1(n)
if(q == 2 | q == 0)
{
k = f2(n)
}
if(q==2 && k ==2)
{
paste( "error at:",as.character(n),"is false")
return(0)
}
return(1)
}
for(i in 1:length(k))
{
n = k[i]
result = f_s(n)
if(result == 0)
break
}
if(result == 0)
{print("False")}
if(result == 1)
print("True")