Skip to main content
Commonmark migration
Source Link

#Brain-Flak, 460 350 270 266 264 188 176 bytes

Brain-Flak, 460 350 270 266 264 188 176 bytes

#Brain-Flak, 460 350 270 266 264 188 176 bytes

Brain-Flak, 460 350 270 266 264 188 176 bytes

Saved more bytes
Source Link
Wheat Wizard
  • 102.9k
  • 23
  • 299
  • 698

#Brain-Flak, 460 350 270 266 264 188188 176 bytes

Try it online!Try it online!

({}[()])(<>((<>()))){{}([(((({}){}))<>)<>({<(({}[()])><>({})<>}>){}<><){}>[)<>[({})]<(())>])](<>)){({}())<>}{}<>{}{}<>(({})){{}{}<>(<(())>)}{}}(<{}{}>)<>{({}[()])<>(({}()[({})])){{}(<({}({}))>)}{}<>}{}<>({}<>) 

The program goes through powers of two and four until it finds one that is larger than the square roota power of two greater than N-1. When it finds it it checks for the divisibility of N-1 by the power of two using modulo and outputs the result

({}[()])  #Subtract one from the input (<>((<>())) ) #Put athree oneones on eachthe other stack { {}  #Pop whateverthe crap is onoff the top ([ ((   ((({})<(({}) #Multiply by two )<>)<>({<({}[()]>)><>({})<>}{}) #Copy#Multiply andthe Squaretop by four and the powerbottom ofby two <><{}>[<>[({})]<(())>]) #|Check if the square ](<>)){({}())<>}{}<>{}{}<>(({})){{}{}<>(<(())>)}{} #|is#Check if the power of four is greater than N-1 } (<{}{}>) #Remove the power of 4 <>{({}[()])<>(({}()[({})])){{}(<({}({}))>)}{}<>}{}<>({}<{}><>) #Modulo N-1 by the power of two 
({}[()])(<>((<>()))){{}([(((({}){}))<>)<>({<(({}[()])><>({})<>}>){}<><){}>[)<>[({})]<(())>])](<>)){({}())<>}{}<>{}{}<>(({})){{}{}<>(<(())>)}{}}(<{}{}>)<>{({}[()])<>(({}()[({})])){{}(<({}({}))>)}{}<>}{}<>({}<><{}><>) 

#Brain-Flak, 460 350 270 266 264 188 bytes

Try it online!

({}[()])(<>(())){{}([(((({}){}))<>)<>({<({}[()])><>({})<>}{}<><{}>[({})]<(())>)](<>)){({}())<>}{}<>{}{}<>(({})){{}{}<>(<(())>)}{}}<>{({}[()])<>(({}()[({})])){{}(<({}({}))>)}{}<>}{}<>({}<>) 

The program goes through powers of two until it finds one that is larger than the square root of N-1. When it finds it it checks for divisibility using modulo and outputs the result

({}[()])  #Subtract one from the input (<>(()))  #Put a one on each stack { {}  #Pop whatever crap is on the top ([ ((   (({}){}) #Multiply by two )<>)<>({<({}[()])><>({})<>}{} #Copy and Square the power of two <><{}>[({})]<(())>) #|Check if the square ](<>)){({}())<>}{}<>{}{}<>(({})){{}{}<>(<(())>)}{} #|is greater than N-1 } <>{({}[()])<>(({}()[({})])){{}(<({}({}))>)}{}<>}{}<>({}<{}><>) #Modulo 
({}[()])(<>(())){{}([(((({}){}))<>)<>({<({}[()])><>({})<>}{}<><{}>[({})]<(())>)](<>)){({}())<>}{}<>{}{}<>(({})){{}{}<>(<(())>)}{}}<>{({}[()])<>(({}()[({})])){{}(<({}({}))>)}{}<>}{}<>({}<>) 

#Brain-Flak, 460 350 270 266 264 188 176 bytes

Try it online!

({}[()])(((<>()))){{}([(((({}<(({}){})>){}){})<>[({})(())])](<>)){({}())<>}{}<>{}{}<>(({})){{}{}<>(<(())>)}{}}(<{}{}>)<>{({}[()])<>(({}()[({})])){{}(<({}({}))>)}{}<>}{}<>({}<>) 

The program goes through powers of two and four until it finds a power of two greater than N-1. When it finds it it checks for the divisibility of N-1 by the power of two using modulo and outputs the result

({}[()]) #Subtract one from input (((<>()))) #Put three ones on the other stack { {} #Pop the crap off the top ([( ((({}<(({}){})>){}){}) #Multiply the top by four and the bottom by two <>[({})(())])](<>)){({}())<>}{}<>{}{}<>(({})){{}{}<>(<(())>)}{} #Check if the power of four is greater than N-1 } (<{}{}>) #Remove the power of 4 <>{({}[()])<>(({}()[({})])){{}(<({}({}))>)}{}<>}{}<>({}<{}><>) #Modulo N-1 by the power of two 
({}[()])(((<>()))){{}([(((({}<(({}){})>){}){})<>[({})(())])](<>)){({}())<>}{}<>{}{}<>(({})){{}{}<>(<(())>)}{}}(<{}{}>)<>{({}[()])<>(({}()[({})])){{}(<({}({}))>)}{}<>}{}<>({}<{}><>) 
Fixed a mistake
Source Link
Wheat Wizard
  • 102.9k
  • 23
  • 299
  • 698

#Brain-Flak, 460 350 270 266 264264 188 bytes

Try it online!Try it online!

({}[()])((<>(())){{}(<([(({}){})<<>(({})<>)>(<>))>)<>{({}[()])<>(({}()[<>({}<({}[())>)])){{}(<({}({}<><>({}[()])>))>)}{}<>}{}<>{}{}([([<><{}<>]>[({})<]<(())>)](<>)){({}())<>}{}<>{}{}<>(({})){{}(<({}<>(<(())>)}{}({}<>)}{}(<()>)<>{({}[()])<>(({}()[({})])){{}(<({}({}))>)}{}<>}{}<>({}<>) 
({}[()])  #Subtract one from the input ((<>(())) #Put two ones on the other stack (the top one just has to be#Put a non-zeroone number)on each stack { {}  #Pop whatever crap is on the top (<[ ((   (({}){}) #Multiply by two  <<>(({})<>)>(<>) #Set up to divide  #Multiply by N-1two )>)  <>{({}[()])<>(({}()[<>({}<({}[())>)])){{}(<({}({}<><>({}[()])>))>)}{}<>}{}<>{}{} #Divide#Copy (Kindof)and Square the power of two ([([ <><{}<>]>[({})<]<(())>) #|Check if the square ](<>)){({}())<>}{}<>{}{}<>(({})){{}(<({}<>(<(())>)}{}({}<>) #Modified#|is lessthangreater checkthan N-1 } {} #Pop the crap (<()>)<>{({}[()])<>(({}()[({})])){{}(<({}({}))>)}{}<>}{}<>({}<><{}><>) #Modified Modulo#Modulo 
({}[()])((<>(())){{}(<([(({}){})<<>(({})<>)>(<>))>)<>{({}[()])<>(({}()[<>({}<({}[())>)])){{}(<({}({}<><>({}[()])>))>)}{}<>}{}<>{}{}([([<><{}<>]>[({})<]<(())>)](<>)){({}())<>}{}<>{}{}<>(({})){{}(<({}<>(<(())>)}{}({}<>)}{}(<()>)<>{({}[()])<>(({}()[({})])){{}(<({}({}))>)}{}<>}{}<>({}<{}><><>) 

#Brain-Flak, 460 350 270 266 264 bytes

Try it online!

({}[()])((<>())){{}(<((({}){})<<>(({})<>)>(<>))>)<>{({}[()])<>(({}()[({}<({}())>)])){{}(<({}({}<({}[()])>))>)}{}<>}{}<>{}{}([([{}<>]({})<(())>)](<>)){({}())<>}{}<>{}{}<>(({})){{}(<({}<>)>)}{}({}<>)}{}(<()>)<>{({}[()])<>(({}()[({})])){{}(<({}({}))>)}{}<>}{}<>({}<>) 
({}[()]) #Subtract one from the input ((<>())) #Put two ones on the other stack (the top one just has to be a non-zero number) { {} #Pop whatever crap is on the top (<( (({}){}) #Multiply by two  <<>(({})<>)>(<>) #Set up to divide by N-1 )>)  <>{({}[()])<>(({}()[({}<({}())>)])){{}(<({}({}<({}[()])>))>)}{}<>}{}<>{}{} #Divide (Kindof) ([([{}<>]({})<(())>)](<>)){({}())<>}{}<>{}{}<>(({})){{}(<({}<>)>)}{}({}<>) #Modified lessthan check } {} #Pop the crap (<()>)<>{({}[()])<>(({}()[({})])){{}(<({}({}))>)}{}<>}{}<>({}<>) #Modified Modulo 
({}[()])((<>())){{}(<((({}){})<<>(({})<>)>(<>))>)<>{({}[()])<>(({}()[({}<({}())>)])){{}(<({}({}<({}[()])>))>)}{}<>}{}<>{}{}([([{}<>]({})<(())>)](<>)){({}())<>}{}<>{}{}<>(({})){{}(<({}<>)>)}{}({}<>)}{}(<()>)<>{({}[()])<>(({}()[({})])){{}(<({}({}))>)}{}<>}{}<>({}<{}><>) 

#Brain-Flak, 460 350 270 266 264 188 bytes

Try it online!

({}[()])(<>(())){{}([(((({}){}))<>)<>({<({}[()])><>({})<>}{}<><{}>[({})]<(())>)](<>)){({}())<>}{}<>{}{}<>(({})){{}{}<>(<(())>)}{}}<>{({}[()])<>(({}()[({})])){{}(<({}({}))>)}{}<>}{}<>({}<>) 
({}[()])  #Subtract one from the input (<>(())) #Put a one on each stack { {}  #Pop whatever crap is on the top ([ ((   (({}){})   #Multiply by two )<>)<>({<({}[()])><>({})<>}{} #Copy and Square the power of two  <><{}>[({})]<(())>) #|Check if the square ](<>)){({}())<>}{}<>{}{}<>(({})){{}{}<>(<(())>)}{} #|is greater than N-1 } <>{({}[()])<>(({}()[({})])){{}(<({}({}))>)}{}<>}{}<>({}<{}><>) #Modulo 
({}[()])(<>(())){{}([(((({}){}))<>)<>({<({}[()])><>({})<>}{}<><{}>[({})]<(())>)](<>)){({}())<>}{}<>{}{}<>(({})){{}{}<>(<(())>)}{}}<>{({}[()])<>(({}()[({})])){{}(<({}({}))>)}{}<>}{}<>({}<>) 
Took off two more bytes
Source Link
Wheat Wizard
  • 102.9k
  • 23
  • 299
  • 698
Loading
Shaved off 4 more bytes
Source Link
Wheat Wizard
  • 102.9k
  • 23
  • 299
  • 698
Loading
Added an actual explanation
Source Link
Wheat Wizard
  • 102.9k
  • 23
  • 299
  • 698
Loading
Golfed some more
Source Link
Wheat Wizard
  • 102.9k
  • 23
  • 299
  • 698
Loading
Fixed the example
Source Link
Wheat Wizard
  • 102.9k
  • 23
  • 299
  • 698
Loading
Source Link
Wheat Wizard
  • 102.9k
  • 23
  • 299
  • 698
Loading