Help:GeSHi: Difference between revisions
m (→{{header|X++}}) |
m (fix Web page URL.) |
||
Line 319: | Line 319: | ||
== Geshi supported formats == |
== Geshi supported formats == |
||
==={{header|Actionscript}}=== |
==={{header|Actionscript}}=== |
||
Web page:[http://www.actionscript.org/ |
Web page:[http://www.actionscript.org/ Actionscript] |
||
Sample: |
Sample: |
||
Line 335: | Line 335: | ||
</ada> |
</ada> |
||
==={{header|AppleScript}}=== |
==={{header|AppleScript}}=== |
||
Web page:[http://www.apple.com/macosx/features/applescript/ |
Web page:[http://www.apple.com/macosx/features/applescript/ AppleScript] |
||
Sample: |
Sample: |
||
Line 348: | Line 348: | ||
</asm> |
</asm> |
||
==={{header|ASP}}=== |
==={{header|ASP}}=== |
||
Web page:[http://www.asp.net/ |
Web page:[http://www.asp.net/ ASP] |
||
Sample: |
Sample: |
||
Line 355: | Line 355: | ||
</asp> |
</asp> |
||
==={{header|AutoIT}}=== |
==={{header|AutoIT}}=== |
||
Web page:[http://www.autoitscript.com/ |
Web page:[http://www.autoitscript.com/ AutoIT] |
||
Sample: |
Sample: |
||
Line 362: | Line 362: | ||
</AutoIT> |
</AutoIT> |
||
==={{header|Backus-Naur form}}=== |
==={{header|Backus-Naur form}}=== |
||
Web page:[http://en.wikipedia.org/wiki/Backus-Naur_form |
Web page:[http://en.wikipedia.org/wiki/Backus-Naur_form Backus-Naur form] |
||
Sample: |
Sample: |
||
Line 369: | Line 369: | ||
</Backus-Naur> |
</Backus-Naur> |
||
==={{header|Bash}}=== |
==={{header|Bash}}=== |
||
Web page:[http://www.gnu.org/software/bash/bash.html |
Web page:[http://www.gnu.org/software/bash/bash.html Bash] |
||
Sample: |
Sample: |
||
Line 376: | Line 376: | ||
</bash> |
</bash> |
||
==={{header|BlitzBasic}}=== |
==={{header|BlitzBasic}}=== |
||
Web page:[http://blitzbasic.com/ |
Web page:[http://blitzbasic.com/ BlitzBasic] |
||
Sample: |
Sample: |
||
Line 383: | Line 383: | ||
</blitzbasic> |
</blitzbasic> |
||
==={{header|CAD DCL}}=== |
==={{header|CAD DCL}}=== |
||
Web page:[http://www.intellicad.org/ |
Web page:[http://www.intellicad.org/ CAD DCL] |
||
Sample: |
Sample: |
||
==={{header|CadLisp}}=== |
==={{header|CadLisp}}=== |
||
Web page:[http://www.intellicad.org/ |
Web page:[http://www.intellicad.org/ CadLisp] |
||
Sample: |
Sample: |
||
Line 394: | Line 394: | ||
</cadlisp> |
</cadlisp> |
||
==={{header|CFDG}}=== |
==={{header|CFDG}}=== |
||
Web page:[http://www.contextfreeart.org/wiki/ |
Web page:[http://www.contextfreeart.org/wiki/ CFDG] |
||
Sample: |
Sample: |
||
Line 407: | Line 407: | ||
</c_mac> |
</c_mac> |
||
==={{header|ColdFusion}}=== |
==={{header|ColdFusion}}=== |
||
Web page:[http://www.macromedia.com/software/coldfusion/ |
Web page:[http://www.macromedia.com/software/coldfusion/ ColdFusion] |
||
Sample: |
Sample: |
||
Line 417: | Line 417: | ||
</csharp> |
</csharp> |
||
==={{header|CSS}}=== |
==={{header|CSS}}=== |
||
Web page:[http://www.w3.org/Style/ |
Web page:[http://www.w3.org/Style/ CSS] |
||
Sample: |
Sample: |
||
Line 424: | Line 424: | ||
</css> |
</css> |
||
==={{header|C++}}=== |
==={{header|C++}}=== |
||
Web page:[http://www.cplusplus.com/ |
Web page:[http://www.cplusplus.com/ C++] |
||
Sample: |
Sample: |
||
Line 431: | Line 431: | ||
</cpp> |
</cpp> |
||
==={{header|C}}=== |
==={{header|C}}=== |
||
Web page:[http://www.cprogramming.org/ |
Web page:[http://www.cprogramming.org/ C] |
||
Sample: |
Sample: |
||
Line 438: | Line 438: | ||
</c> |
</c> |
||
==={{header|Delphi}}=== |
==={{header|Delphi}}=== |
||
Web page:[http://www.borland.com/ |
Web page:[http://www.borland.com/ Delphi] |
||
Sample: |
Sample: |
||
Line 445: | Line 445: | ||
</delphi> |
</delphi> |
||
==={{header|DIV}}=== |
==={{header|DIV}}=== |
||
Web page:[http://div-arena.com/ |
Web page:[http://div-arena.com/ DIV] |
||
Sample: |
Sample: |
||
Line 464: | Line 464: | ||
</d> |
</d> |
||
==={{header|Eiffel}}=== |
==={{header|Eiffel}}=== |
||
Web page:[http://eiffel.com/ |
Web page:[http://eiffel.com/ Eiffel] |
||
Sample: |
Sample: |
||
Line 471: | Line 471: | ||
</eiffel> |
</eiffel> |
||
==={{header|Fortran}}=== |
==={{header|Fortran}}=== |
||
Web page:[http://en.wikipedia.org/wiki/Fortran |
Web page:[http://en.wikipedia.org/wiki/Fortran Fortran] |
||
Sample: |
Sample: |
||
Line 484: | Line 484: | ||
==={{header|FreeBasic}}=== |
==={{header|FreeBasic}}=== |
||
Web page:[http://www.freebasic.net/ |
Web page:[http://www.freebasic.net/ FreeBasic] |
||
Sample: |
Sample: |
||
Line 491: | Line 491: | ||
</freebasic> |
</freebasic> |
||
==={{header|GML}}=== |
==={{header|GML}}=== |
||
Web page:[http://www.gamemaker.nl/ |
Web page:[http://www.gamemaker.nl/ GML] |
||
Sample: |
Sample: |
||
Line 498: | Line 498: | ||
</gml> |
</gml> |
||
==={{header|Groovy}}=== |
==={{header|Groovy}}=== |
||
Web page:[http://groovy.codehaus.org/ |
Web page:[http://groovy.codehaus.org/ Groovy] |
||
Sample: |
Sample: |
||
Line 505: | Line 505: | ||
</Groovy> |
</Groovy> |
||
==={{header|HTML}}=== |
==={{header|HTML}}=== |
||
Web page:[http://www.w3.org/TR/REC-html40/ |
Web page:[http://www.w3.org/TR/REC-html40/ HTML] |
||
Sample: |
Sample: |
||
Line 512: | Line 512: | ||
</html4strict> |
</html4strict> |
||
==={{header|Inno}}=== |
==={{header|Inno}}=== |
||
Web page:[http://www.jrsoftware.org/isinfo.php |
Web page:[http://www.jrsoftware.org/isinfo.php Inno] |
||
Sample: |
Sample: |
||
Line 519: | Line 519: | ||
</inno> |
</inno> |
||
==={{header|IO}}=== |
==={{header|IO}}=== |
||
Web page:[http://www.iolanguage.com/about/ |
Web page:[http://www.iolanguage.com/about/ IO] |
||
Sample: |
Sample: |
||
Line 526: | Line 526: | ||
</IO> |
</IO> |
||
==={{header|Java 5}}=== |
==={{header|Java 5}}=== |
||
Web page:[http://java.sun.com/ |
Web page:[http://java.sun.com/ Java 5] |
||
Sample: |
Sample: |
||
Line 533: | Line 533: | ||
</java> |
</java> |
||
==={{header|Javascript}}=== |
==={{header|Javascript}}=== |
||
Web page:[http://www.javascript.com/ |
Web page:[http://www.javascript.com/ Javascript] |
||
Sample: |
Sample: |
||
Line 540: | Line 540: | ||
</javascript> |
</javascript> |
||
==={{header|Java}}=== |
==={{header|Java}}=== |
||
Web page:[http://java.sun.com/ |
Web page:[http://java.sun.com/ Java] |
||
Sample: |
Sample: |
||
Line 547: | Line 547: | ||
</java> |
</java> |
||
==={{header|LaTeX}}=== |
==={{header|LaTeX}}=== |
||
Web page:[http://www.latex-project.org/ |
Web page:[http://www.latex-project.org/ LaTeX] |
||
Sample: |
Sample: |
||
Line 557: | Line 557: | ||
==={{header|Lisp}}=== |
==={{header|Lisp}}=== |
||
Web page:[http://www.lisp.org/ |
Web page:[http://www.lisp.org/ Lisp] |
||
Sample: |
Sample: |
||
Line 564: | Line 564: | ||
</lisp> |
</lisp> |
||
==={{header|Lua}}=== |
==={{header|Lua}}=== |
||
Web page:[http://www.lua.org/ |
Web page:[http://www.lua.org/ Lua] |
||
Sample: |
Sample: |
||
Line 584: | Line 584: | ||
</mpasm> |
</mpasm> |
||
==={{header|MySQL}}=== |
==={{header|MySQL}}=== |
||
Web page:[http://mysql.com/ |
Web page:[http://mysql.com/ MySQL] |
||
Sample: |
Sample: |
||
Line 591: | Line 591: | ||
</mysql> |
</mysql> |
||
==={{header|NSIS}}=== |
==={{header|NSIS}}=== |
||
Web page:[http://nsis.sourceforge.net/ |
Web page:[http://nsis.sourceforge.net/ NSIS] |
||
Sample: |
Sample: |
||
Line 604: | Line 604: | ||
</objc> |
</objc> |
||
==={{header|OCaml}}=== |
==={{header|OCaml}}=== |
||
Web page:[http://caml.inria.fr/ |
Web page:[http://caml.inria.fr/ OCaml] |
||
Sample: |
Sample: |
||
Line 614: | Line 614: | ||
</ocaml> |
</ocaml> |
||
==={{header|OpenOffice BASIC}}=== |
==={{header|OpenOffice BASIC}}=== |
||
Web page:[http://www.openoffice.org/ |
Web page:[http://www.openoffice.org/ OpenOffice BASIC] |
||
Sample: |
Sample: |
||
Line 621: | Line 621: | ||
</oobas> |
</oobas> |
||
==={{header|Oracle 8 SQL}}=== |
==={{header|Oracle 8 SQL}}=== |
||
Web page:[http://www.oracle.com/ |
Web page:[http://www.oracle.com/ Oracle 8 SQL] |
||
Sample: |
Sample: |
||
Line 634: | Line 634: | ||
</pascal> |
</pascal> |
||
==={{header|Perl}}=== |
==={{header|Perl}}=== |
||
Web page:[http://www.perl.com/ |
Web page:[http://www.perl.com/ Perl] |
||
Sample: |
Sample: |
||
Line 641: | Line 641: | ||
</perl> |
</perl> |
||
==={{header|PHP}}=== |
==={{header|PHP}}=== |
||
Web page:[http://www.php.net/ |
Web page:[http://www.php.net/ PHP] |
||
Sample: |
Sample: |
||
Line 651: | Line 651: | ||
</php-brief> |
</php-brief> |
||
==={{header|PL/SQL}}=== |
==={{header|PL/SQL}}=== |
||
Web page:[http://en.wikipedia.org/wiki/PL/SQL |
Web page:[http://en.wikipedia.org/wiki/PL/SQL PL/SQL] |
||
Sample: |
Sample: |
||
Line 658: | Line 658: | ||
</PLSQL> |
</PLSQL> |
||
==={{header|Python}}=== |
==={{header|Python}}=== |
||
Web page:[http://www.python.org/ |
Web page:[http://www.python.org/ Python] |
||
Sample: |
Sample: |
||
Line 665: | Line 665: | ||
</python> |
</python> |
||
==={{header|QBASIC}}=== |
==={{header|QBASIC}}=== |
||
Web page:[http://qbnz.com/ |
Web page:[http://qbnz.com/ Q(uick)BASIC] |
||
Sample: |
Sample: |
||
Line 672: | Line 672: | ||
</qbasic> |
</qbasic> |
||
==={{header|Ruby}}=== |
==={{header|Ruby}}=== |
||
Web page:[http://ruby-lang.org/ |
Web page:[http://ruby-lang.org/ Ruby] |
||
Sample: |
Sample: |
||
Line 682: | Line 682: | ||
Check tag and insert here: ? |
Check tag and insert here: ? |
||
</SAS> |
</SAS> |
||
Web page:[http://en.wikipedia.org/wiki/SAS_programming_language |
Web page:[http://en.wikipedia.org/wiki/SAS_programming_language SAS] |
||
==={{header|Scheme}}=== |
==={{header|Scheme}}=== |
||
Web page:[http://schemers.org/ |
Web page:[http://schemers.org/ Scheme] |
||
Sample: |
Sample: |
||
Line 691: | Line 691: | ||
</scheme> |
</scheme> |
||
==={{header|SDLBasic}}=== |
==={{header|SDLBasic}}=== |
||
Web page:[http://sdlbasic.sf.net/ |
Web page:[http://sdlbasic.sf.net/ SDLBasic] |
||
Sample: |
Sample: |
||
Line 698: | Line 698: | ||
</sdlbasic> |
</sdlbasic> |
||
==={{header|Smalltalk}}=== |
==={{header|Smalltalk}}=== |
||
Web page:[http://en.wikipedia.org/wiki/Smalltalk_programming_language |
Web page:[http://en.wikipedia.org/wiki/Smalltalk_programming_language Smalltalk] |
||
Sample: |
Sample: |
||
Line 705: | Line 705: | ||
</Smalltalk> |
</Smalltalk> |
||
==={{header|Smarty}}=== |
==={{header|Smarty}}=== |
||
Web page:[http://smarty.php.net/ |
Web page:[http://smarty.php.net/ Smarty] |
||
Sample: |
Sample: |
||
Line 718: | Line 718: | ||
</sql> |
</sql> |
||
==={{header|TCL}}=== |
==={{header|TCL}}=== |
||
Web page:[http://www.tcl.tk/ |
Web page:[http://www.tcl.tk/ TCL] |
||
Sample: |
Sample: |
||
Line 725: | Line 725: | ||
</TCL> |
</TCL> |
||
==={{header|thinBasic}}=== |
==={{header|thinBasic}}=== |
||
Web page:[http://www.thinbasic.com/ |
Web page:[http://www.thinbasic.com/ thinBasic] |
||
Sample: |
Sample: |
||
Line 736: | Line 736: | ||
</T-SQL> |
</T-SQL> |
||
==={{header|Uno IDL}}=== |
==={{header|Uno IDL}}=== |
||
Web page:[http://wiki.services.openoffice.org/wiki/Uno/Article/Understanding_Uno |
Web page:[http://wiki.services.openoffice.org/wiki/Uno/Article/Understanding_Uno Uno IDL] |
||
Sample: |
Sample: |
||
Line 743: | Line 743: | ||
</Uno IDL> |
</Uno IDL> |
||
==={{header|VB.NET}}=== |
==={{header|VB.NET}}=== |
||
Web page:[http://msdn.microsoft.com/ |
Web page:[http://msdn.microsoft.com/ VB.NET] |
||
Sample: |
Sample: |
||
Line 750: | Line 750: | ||
</vb> |
</vb> |
||
==={{header|Visual BASIC}}=== |
==={{header|Visual BASIC}}=== |
||
Web page:[http://msdn.microsoft.com/vbasic/ |
Web page:[http://msdn.microsoft.com/vbasic/ Visual BASIC] |
||
Sample: |
Sample: |
||
Line 757: | Line 757: | ||
</vbnet> |
</vbnet> |
||
==={{header|Visual Fox Pro}}=== |
==={{header|Visual Fox Pro}}=== |
||
Web page:[http://msdn.microsoft.com/vfoxpro/ |
Web page:[http://msdn.microsoft.com/vfoxpro/ Visual Fox Pro] |
||
Sample: |
Sample: |
||
Line 770: | Line 770: | ||
</vhdl> |
</vhdl> |
||
==={{header|Winbatch}}=== |
==={{header|Winbatch}}=== |
||
Web page:[http://winbatch.com/ |
Web page:[http://winbatch.com/ Winbatch] |
||
Sample: |
Sample: |
||
Line 777: | Line 777: | ||
</Winbatch> |
</Winbatch> |
||
==={{header|X++}}=== |
==={{header|X++}}=== |
||
Web page:[http://msdn2.microsoft.com/en-us/library/aa867122.aspx |
Web page:[http://msdn2.microsoft.com/en-us/library/aa867122.aspx X++] |
||
Sample: |
Sample: |
||
<Xpl> |
<Xpl> |
||
Line 784: | Line 784: | ||
==={{header|Z80 ASM}}=== |
==={{header|Z80 ASM}}=== |
||
Web page:[http://en.wikipedia.org/wiki/Zilog_Z80#The_Z80_assembly_language |
Web page:[http://en.wikipedia.org/wiki/Zilog_Z80#The_Z80_assembly_language Z80 ASM] |
||
Sample: |
Sample: |
||
== Other GeSHi file formats == |
== Other GeSHi file formats == |
||
==={{header|Apache Log}}=== |
==={{header|Apache Log}}=== |
||
Web page:[http://www.apache.org/ |
Web page:[http://www.apache.org/ Apache Log] |
||
Sample: |
Sample: |
||
Line 802: | Line 802: | ||
</ini> |
</ini> |
||
==={{header|mIRC}}=== |
==={{header|mIRC}}=== |
||
Web page:[http://mirc.com/ |
Web page:[http://mirc.com/ mIRC] |
||
Sample: |
Sample: |
||
Line 809: | Line 809: | ||
</mIRC> |
</mIRC> |
||
==={{header|robots.txt}}=== |
==={{header|robots.txt}}=== |
||
Web page:[http://www.robotstxt.org/wc/norobots.html |
Web page:[http://www.robotstxt.org/wc/norobots.html robots.txt] |
||
Sample: |
Sample: |
||
Line 816: | Line 816: | ||
</robots.txt> |
</robots.txt> |
||
==={{header|XML}}=== |
==={{header|XML}}=== |
||
Web page:[http://www.xml.com/ |
Web page:[http://www.xml.com/ XML] |
||
Sample: |
Sample: |
Revision as of 03:41, 23 February 2008
GeSHi is currently in Beta on Rosetta Code. Please do not employ it anywhere other than this page for now. --Short Circuit 20:07, 22 February 2008 (MST)
You are encouraged to solve this task according to the task description, using any language you may know.
The following are examples of typical code formated with GeSHi, the Generic Syntax Hilighter.
Supported source tags
GeSHi currently supports the following tags: actionscript-french, actionscript, ada, apache, applescript, asm, asp, bash, blitzbasic, caddcl, cadlisp, c_mac, c, cpp, csharp, css, delphi, diff, dos, d, eiffel, freebasic, gml, html4strict, ini, inno, java, javascript, lisp, lua, matlab, mpasm, mysql, nsis, objc, ocaml-brief, ocaml, oobas, oracle8, pascal, perl, php-brief, php, python, qbasic, ruby, scheme, sdlbasic, smarty, sql, vbnet, vb, vhdl, visualfoxpro & xml.
Use trial division. Even numbers may be eliminated right away. A loop from 3 to √(n) will suffice, but other loops are allowed.
Initial examples
Ada
<Ada>
function Is_Prime(Item : Positive) return Boolean is Result : Boolean := True; Test : Natural; begin if Item /= 2 and Item mod 2 = 0 then Result := False; else Test := 3; while Test < Integer(Sqrt(Float(Item))) loop if Item mod Test = 0 then Result := False; exit; end if; Test := Test + 2; end loop; end if; return Result; end Is_Prime;
</Ada>
ALGOL 68
<ALGOL_68>
main:( PROC is prime = ( INT n )BOOL: ( IF n = 2 THEN TRUE ELIF n <= 1 OR n MOD 2 = 0 THEN FALSE ELSE BOOL prime := TRUE; FOR i FROM 3 BY 2 TO ENTIER sqrt(n) WHILE prime := n MOD i /= 0 DO SKIP OD; prime FI ); INT upb=100; printf(($" The primes up to "g(-3)" are:"l$,upb)); FOR i TO upb DO IF is prime(i) THEN printf(($g(-4)$,i)) FI OD; printf($l$) )
Output: </ALGOL_68>
The primes up to 100 are: 2 3 5 7 11 13 17 19 23 29 31 37 41 43 47 53 59 61 67 71 73 79 83 89 97
BASIC
Going with the classic 1 for "true" and 0 for "false": <qbasic>
FUNCTION prime% (n!) IF n = 2 THEN prime = 1 IF n <= 1 OR n MOD 2 = 0 THEN prime = 0 FOR a = 3 TO INT(SQR(n)) STEP 2 IF n MOD a = 0 THEN prime = 0 NEXT a prime = 1 END FUNCTION
</qbasic>
C
<C> <source lang=C>
#include <math.h> #define FALSE 0 #define TRUE 1 int isPrime( unsigned int n ) { unsigned int i; if ( n === 2 ) return TRUE; if ( n <= 1 || ( n & 1 ) === 0 ) return FALSE; for ( i = 3 ; i <= sqrt( n ) ; i += 2 ) if ( n % i === 0 ) return FALSE; return TRUE; }
</C>
Common Lisp
<lisp>
(defun primep (a) (cond ((= a 2) T) ((or (<= a 1) (= (mod a 2) 0)) nil) ((loop for i from 3 to (sqrt a) by 2 do (if (= (mod a i) 0) (return nil))) nil) (T T)))
</lisp>
D
<D>
import std.math: sqrt; bool isPrime(int n) { if (n === 2) return true; if (n <= 1 || (n & 1) === 0) return false; for(int i = 3; i <= sqrt(cast(float)n); i += 2) if (n % i === 0) return false; return true; }
</D>
Forth
<Forth>
: prime? ( n -- ? ) dup 2 < if drop false else dup 2 = if drop true else dup 1 and 0= if drop false else 3 begin 2dup dup * >= while 2dup mod 0= if 2drop false exit then 2 + repeat 2drop true then then then ;
</Forth>
Haskell
Without square roots: <Haskell>
divides k n = n `mod` k === 0 isPrime :: Integer -> Bool isPrime n | n < 2 = False isPrime n = not $ any (`divides` n) $ takeWhile (\k -> k*k <= n) [2..]
</Haskell>
J
Actually 1&p: would do, but the task calls for trial division, so: <J>
isprime=: 3 : 'if. 3>:y do. 1<y else. 0 *./@:< y|~2+i.<.%:y end.'
</J>
Java
<Java>
public static boolean prime(double a){ if(a === 2){ return true; }else if(a <= 1 || a % 2 === 0){ return false; } for(long n= 3; n <= (long)Math.sqrt(a); n+= 2){ if(a % n === 0){ return false; } } return true; }
</Java>
LSE64
<LSE64>
over : 2 pick 2dup : over over even? : 1 & 0 = # trial n d yields "n d 0/1 false" or "n d+2 true" trial : 2 + true trial : 2dup % 0 = then 0 false trial : 2dup dup * < then 1 false trial-loop : trial &repeat # prime? n yields flag prime? : 3 trial-loop >flag drop drop prime? : dup even? then drop false prime? : dup 2 = then drop true prime? : dup 2 < then drop false
</LSE64>
MAXScript
<MAXScript>
fn isPrime n = ( if n === 2 then ( return true ) else if (n <= 1) OR (mod n 2 === 0) then ( return false ) for i in 3 to (sqrt n) by 2 do ( if mod n i === 0 then return false ) true )
</MAXScript>
Perl
<Perl>
sub prime { $a = shift; if ($a === 2) { return 1; } if ($a <= 1 || $a % 2 === 0) { return 0; } $d = 3; while ($d <= sqrt($a)) { if ($a % $d === 0) { return 0; } $d += 2; } return 1; }
</Perl>
Python
The simplest primality test, using trial division:
<Python> def prime(a):
return not (a < 2 or any(a % x === 0 for x in range(2, int(a**0.5) + 1)))
</Python>
Another test. Exclude even numbers first:
<Python> def prime2(a):
if a === 2: return True if a < 2 or a % 2 === 0: return False return not any(a % x === 0 for x in range(3, int(a**0.5) + 1, 2))
</Python>
Yet another test. Exclude multiples of 2 and 3, see http://www.devx.com/vb2themax/Tip/19051:
<Python> def prime3(a):
if a < 2: return False if a === 2 or a === 3: return True # manually test 2 and 3 if a % 2 === 0 or a % 3 === 0: return False # exclude multiples of 2 and 3
maxDivisor = a**0.5 d, i = 5, 2 while d <= maxDivisor: if a % d === 0: return False d += i i = 6 - i # this modifies 2 into 4 and viceversa
return True
</Python>
Ruby
def prime(a) if a===2 return true end if a<=1 || a%2===0 return false end d=3 while d <= Math.sqrt(a) do if a%d===0 return false end d+=2 end return true end
TI-83 BASIC
Calculator symbol translations:
"STO" arrow: →
Square root sign: √ <TI-83 BASIC>
Prompt A If A=2:Then Disp "PRIME" Stop End If (fPart(A/2)=0 and A>0) or A<2:Then Disp "NOT PRIME" Stop End 1→P For(B,3,√(A)) If FPart(A/B)=0:Then 0→P √(A)→B End B+1→B End If P=1:Then Disp "PRIME" Else Disp "NOT PRIME" End
</TI-83 BASIC>
Geshi supported formats
Actionscript
Web page:Actionscript
Sample: <actionscript>
Insert code here: ?
</actionscript> <actionscript-french>
Insert code here: ?
</actionscript-french>
ADA
Sample: <ada>
Insert code here: ?
</ada>
AppleScript
Web page:AppleScript
Sample: <applescript>
Insert code here: ?
</applescript>
ASM
Sample: <asm>
Insert code here: ?
</asm>
ASP
Web page:ASP
Sample: <asp>
Insert code here: ?
</asp>
AutoIT
Web page:AutoIT
Sample: <AutoIT>
Check tag and insert here: ?
</AutoIT>
Backus-Naur form
Web page:Backus-Naur form
Sample: <Backus-Naur>
Check tag and insert here: ?
</Backus-Naur>
Bash
Web page:Bash
Sample: <bash>
Insert code here: ?
</bash>
BlitzBasic
Web page:BlitzBasic
Sample: <blitzbasic>
Insert code here: ?
</blitzbasic>
CAD DCL
Web page:CAD DCL
Sample:
CadLisp
Web page:CadLisp
Sample: <cadlisp>
Insert code here: ?
</cadlisp>
CFDG
Web page:CFDG
Sample: <CFDG>
Check tag and insert here: ?
</CFDG>
C for Macs
Sample: <c_mac>
Insert code here: ?
</c_mac>
ColdFusion
Web page:ColdFusion
Sample:
C#
Sample: <csharp>
Insert code here: ?
</csharp>
CSS
Web page:CSS
Sample: <css>
Insert code here: ?
</css>
C++
Web page:C++
Sample: <cpp>
Insert code here: ?
</cpp>
C
Web page:C
Sample: <c>
Insert code here: ?
</c>
Delphi
Web page:Delphi
Sample: <delphi>
Insert code here: ?
</delphi>
DIV
Web page:DIV
Sample: <diff>
Insert code here: ?
</diff>
DOS
Sample: <dos>
Insert code here: ?
</dos>
D
Sample: <d>
Insert code here: ?
</d>
Eiffel
Web page:Eiffel
Sample: <eiffel>
Insert code here: ?
</eiffel>
Fortran
Web page:Fortran
Sample: <Fortran>
Insert code here: ? PROGRAM MAIN INTEGER I CALL SUBROUTINE STOP EXIT
</Fortran>
FreeBasic
Web page:FreeBasic
Sample: <freebasic>
Insert code here: ?
</freebasic>
GML
Web page:GML
Sample: <gml>
Insert code here: ?
</gml>
Groovy
Web page:Groovy
Sample: <Groovy>
Check tag and insert here: ?
</Groovy>
HTML
Web page:HTML
Sample: <html4strict>
Insert code here: ?
</html4strict>
Inno
Web page:Inno
Sample: <inno>
Insert code here: ?
</inno>
IO
Web page:IO
Sample: <IO>
Insert code here: ?
</IO>
Java 5
Web page:Java 5
Sample: <java>
Insert code here: ?
</java>
JavaScript
Web page:Javascript
Sample: <javascript>
Insert code here: ?
</javascript>
Java
Web page:Java
Sample: <java>
Insert code here: ?
</java>
LaTeX
Web page:LaTeX
Sample: <LaTeX>
Insert code here: ?
</LaTex>
Lisp
Web page:Lisp
Sample: <lisp>
Insert code here: ?
</lisp>
Lua
Web page:Lua
Sample: <lua>
Insert code here: ?
</lua>
MatLab
Sample: <matlab>
Insert code here: ?
</matlab>
Microprocessor ASM
mpasm
Sample: <mpasm>
Insert code here: ?
</mpasm>
MySQL
Web page:MySQL
Sample: <mysql>
Insert code here: ?
</mysql>
NSIS
Web page:NSIS
Sample: <nsis>
Insert code here: ?
</nsis>
Objective C
Sample: <objc>
Insert code here: ?
</objc>
OCaml
Web page:OCaml
Sample: <ocaml-brief>
Insert code here: ?
</ocaml-brief> <ocaml>
Insert code here: ?
</ocaml>
OpenOffice BASIC
Web page:OpenOffice BASIC
Sample: <oobas>
Insert code here: ?
</oobas>
Oracle 8 SQL
Web page:Oracle 8 SQL
Sample: <oracle8>
Insert code here: ?
</oracle8>
Pascal
Sample: <pascal>
Insert code here: ?
</pascal>
Perl
Web page:Perl
Sample: <perl>
Insert code here: ?
</perl>
PHP
Web page:PHP
Sample: <php>
Insert code here: ?
</php> <php-brief>
Insert code here: ?
</php-brief>
PL/SQL
Web page:PL/SQL
Sample: <PLSQL>
Check tag and insert here: ?
</PLSQL>
Python
Web page:Python
Sample: <python>
Insert code here: ?
</python>
QBASIC
Web page:Q(uick)BASIC
Sample: <qbasic>
Insert code here: ?
</qbasic>
Ruby
Web page:Ruby
Sample:
Insert code here: ?
SAS
<SAS>
Check tag and insert here: ?
</SAS> Web page:SAS
Scheme
Web page:Scheme
Sample: <scheme>
Insert code here: ?
</scheme>
SDLBasic
Web page:SDLBasic
Sample: <sdlbasic>
Insert code here: ?
</sdlbasic>
Smalltalk
Web page:Smalltalk
Sample: <Smalltalk>
Check tag and insert here: ?
</Smalltalk>
Smarty
Web page:Smarty
Sample: <smarty>
Insert code here: ?
</smarty>
SQL
Sample: <sql>
Insert code here: ?
</sql>
TCL
Web page:TCL
Sample: <TCL>
Check tag and insert here: ?
</TCL>
thinBasic
Web page:thinBasic
Sample: <ThinBasic>
Check tag and insert here: ?
</ThinBasic>
T-SQL
<T-SQL>
Check tag and insert here: ?
</T-SQL>
Uno IDL
Web page:Uno IDL
Sample: <Uno IDL>
Check tag and insert here: ?
</Uno IDL>
VB.NET
Web page:VB.NET
Sample: <vb>
Insert code here: ?
</vb>
Visual BASIC
Web page:Visual BASIC
Sample: <vbnet>
Insert code here: ?
</vbnet>
Visual Fox Pro
Web page:Visual Fox Pro
Sample: <visualfoxpro>
Insert code here: ?
</visualfoxpro>
Visual VHDL
Sample: <vhdl>
Insert code here: ?
</vhdl>
Winbatch
Web page:Winbatch
Sample: <Winbatch>
Check tag and insert here: ?
</Winbatch>
X++
Web page:X++ Sample: <Xpl>
Insert code here: ?
</Xpl>
Z80 ASM
Web page:Z80 ASM
Sample:
Other GeSHi file formats
Apache Log
Web page:Apache Log
Sample: <apache>
Insert code here: ?
</apache>
Ini
Sample: <ini>
Insert code here: ?
</ini>
mIRC
Web page:mIRC
Sample: <mIRC>
Check tag and insert here: ?
</mIRC>
robots.txt
Web page:robots.txt
Sample: <robots.txt>
Check tag and insert here: ?
</robots.txt>
XML
Web page:XML
Sample: <xml>
Insert code here: ?
</xml>
- Less Than 20 Examples
- Programming Tasks
- Solutions by Programming Task
- Prime Numbers
- Ada
- ALGOL 68
- BASIC
- C
- Common Lisp
- D
- Forth
- Haskell
- J
- Java
- LSE64
- MAXScript
- Perl
- Python
- Ruby
- TI-83 BASIC
- Actionscript
- ADA
- AppleScript
- ASM
- ASP
- AutoIT
- Backus-Naur form
- Bash
- BlitzBasic
- CAD DCL
- CadLisp
- CFDG
- C for Macs
- ColdFusion
- C sharp
- CSS
- C++
- Delphi
- DIV
- DOS
- Eiffel
- Fortran
- FreeBasic
- GML
- Groovy
- HTML
- Inno
- IO
- Java 5
- JavaScript
- LaTeX
- Lisp
- Lua
- MatLab
- Microprocessor ASM
- Mpasm
- MySQL
- NSIS
- Objective C
- OCaml
- OpenOffice BASIC
- Oracle 8 SQL
- Pascal
- PHP
- PL/SQL
- QBASIC
- SAS
- Scheme
- SDLBasic
- Smalltalk
- Smarty
- SQL
- TCL
- ThinBasic
- T-SQL
- Uno IDL
- VB.NET
- Visual BASIC
- Visual Fox Pro
- Visual VHDL
- Winbatch
- X++
- Z80 ASM
- Apache Log
- Ini
- MIRC
- Robots.txt
- XML