Guest User

Untitled

a guest
Jan 23rd, 2019
96
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.48 KB | None | 0 0
  1. N = k * 2^n + 1
  2.  
  3. (1 * 2^1) + 1
  4.  
  5. (1 * 2^2) + 1
  6.  
  7. (3 * 2^1) + 1
  8.  
  9. 3, 5, 9, 13, 17, 25, 33, 41, 49, 57, 65, 81, 97, 113, 129, 145, 161, 177, 193, 209, 225, 241, 257, 289, 321, 353, 385, 417, 449, 481, 513, 545, 577, 609, 641, 673, 705, 737, 769, 801, 833, 865, 897, 929, 961, 993
  10.  
  11. ’&C²>
  12.  
  13. ’&C²> Main link. Argument: N
  14.  
  15. ’ Decrement; yield N - 1.
  16. C Complement; yield 1 - N.
  17. & Take the bitwise AND of both results.
  18. ² Square the bitwise AND.
  19. > Compare the square to N.
  20.  
  21. 1<#<4^IntegerExponent[#-1,2]&
  22.  
  23. Reap[Do[If[f[i],Sow[i]],{i,1,1000}]][[2,1]]
  24.  
  25. {3, 5, 9, 13, 17, 25, 33, 41, 49, 57, 65, 81, 97, 113, 129, 145, 161, 177, 193, 209, 225, 241, 257, 289, 321, 353, 385, 417, 449, 481, 513, 545, 577, 609, 641, 673, 705, 737, 769, 801, 833, 865, 897, 929, 961, 993}
  26.  
  27. BitAnd[#-1,1-#]^2>#&
  28.  
  29. <©Ó¬oD®s/›
  30.  
  31. [2, 2, 2, 2, 3, 5]
  32.  
  33. [2, 2, 2, 2]
  34.  
  35. [3, 5]
  36.  
  37. qtYF1)EW<
  38.  
  39. q % Input x implicitly. Subtract 1
  40. t % Duplicate
  41. YF % Exponents of prime factorization of x-1
  42. 1) % First entry: exponent of 2. Errors for x equal to 1 or 2
  43. E % Duplicate
  44. W % 2 raised to that. This is y squared
  45. < % Is x-1 less than y squared? Implicitly display
  46.  
  47. f x=length [x|k<-[1,3..x],n<-[1..x],k*2^n+1==x,2^n>k]>0
  48.  
  49. f x=or[k*2^n+1==x|k<-[1,3..x],n<-[1..x],2^n>k]
  50.  
  51. ({}[()])(((<>()))){{}([(((({}<(({}){})>){}){})<>[({})(())])](<>)){({}())<>}{}<>{}{}<>(({})){{}{}<>(<(())>)}{}}(<{}{}>)<>{({}[()])<>(({}()[({})])){{}(<({}({}))>)}{}<>}{}<>({}<>)
  52.  
  53. ({}[()]) #Subtract one from input
  54. (((<>()))) #Put three ones on the other stack
  55. {
  56. {} #Pop the crap off the top
  57. ([(
  58. ((({}<(({}){})>){}){}) #Multiply the top by four and the bottom by two
  59. <>[({})(())])](<>)){({}())<>}{}<>{}{}<>(({})){{}{}<>(<(())>)}{} #Check if the power of four is greater than N-1
  60. }
  61. (<{}{}>) #Remove the power of 4
  62. <>{({}[()])<>(({}()[({})])){{}(<({}({}))>)}{}<>}{}<>({}<{}><>) #Modulo N-1 by the power of two
  63.  
  64. ({}[()])(((<>()))){{}([(((({}<(({}){})>){}){})<>[({})(())])](<>)){({}())<>}{}<>{}{}<>(({})){{}{}<>(<(())>)}{}}(<{}{}>)<>{({}[()])<>(({}()[({})])){{}(<({}({}))>)}{}<>}{}<>({}<{}><>)
  65.  
  66. >N>0,2:N^P:K*+?,P>K:2%1,N:K=
  67.  
  68. >N>0,2:N^P:K*+?,P>K:2%1,N:K=
  69.  
  70. >N>0 input > N > 0
  71. 2:N^P 2^N = P
  72. P:K*+? P*K+1 = input
  73. P>K P > K
  74. K:2%1 K%2 = 1
  75. N:K= [N:K] has a solution
  76.  
  77. !x=~-x&-~-x>x^.5
  78.  
  79. x=scan()-1;n=0;while(!x%%2){x=x/2;n=n+1};2^(2*n)>x
  80.  
  81. %:<<:AND-.
  82.  
  83. f =: %:<<:AND-.
  84. f 16
  85. 0
  86. f 17
  87. 1
  88. (#~f"0) >: i. 100 NB. Filter the numbers [1, 100]
  89. 3 5 9 13 17 25 33 41 49 57 65 81 97
  90.  
  91. %:<<:AND-. Input: n
  92. -. Complement. Compute 1-n
  93. <: Decrement. Compute n-1
  94. AND Bitwise-and between 1-n and n-1
  95. %: Square root of n
  96. < Compare sqrt(n) < ((1-n) & (n-1))
  97.  
  98. boolean g(int p){return p--<(p&-p)*(p&-p);}
  99.  
  100. boolean f(int p){return(p-1&(1-p))>Math.sqrt(p);}
  101.  
  102. boolean g(int p){return Math.pow(p-1&(1-p),2)>p;}
  103.  
  104. double g(int p){return Math.pow(p-1&(1-p),2)-p;}
  105.  
  106. ((p - 1 & (1 - p))^2) > p;
  107.  
  108. qi_(_W*&2#<
  109.  
  110. IsProth:=proc(X)local n:=0;local x:=X-1;while x mod 2<>1 do x:=x/2;n:=n+1;end do;is(2^n>x);end proc:
  111.  
  112. IsProth := proc( X )
  113. local n := 0;
  114. local x := X - 1;
  115. while x mod 2 <> 1 do
  116. x := x / 2;
  117. n := n + 1;
  118. end do;
  119. is( 2^n > x );
  120. end proc:
  121.  
  122. x=>x--<(-x&x)**2
  123.  
  124. d+
  125. $*
  126. +`(1+)1
  127. $+0
  128. 01
  129. 1
  130. +`.10(0*1)$
  131. 1$1
  132. ^10*1$
  133.  
  134. d+
  135. $*
  136.  
  137. +`(1+)1
  138. $+0
  139. 01
  140. 1
  141.  
  142. +`.10(0*1)$
  143. 1$1
  144.  
  145. ^10*1$
Add Comment
Please, Sign In to add comment