EnglishРусский  

   ..

   eratosthenes.1.g

The project is closed! You can look at a new scripting language. It is available on GitHub.
Also, try our open source cross-platform automation software.

Ads

Installer and installation software
Commercial and Freeware installers.

source\samples\primenumber\eratosthenes.1.g
 1 /******************************************************************************
 2 *
 3 * Copyright (C) 2005, The Gentee Group. All rights reserved. 
 4 * This file is part of the Gentee open source project - http://www.gentee.com. 
 5 * 
 6 * THIS FILE IS PROVIDED UNDER THE TERMS OF THE GENTEE LICENSE ("AGREEMENT"). 
 7 * ANY USE, REPRODUCTION OR DISTRIBUTION OF THIS FILE CONSTITUTES RECIPIENTS 
 8 * ACCEPTANCE OF THE AGREEMENT.
 9 *
10 * ID: eratosthenes 17.10.06 0.0.A.
11 *
12 * Author: Alexey Krivonogov ( gentee )
13 *
14 ******************************************************************************/
15 
16 func main<main>
17 {
18    str   input
19    uint  high i j
20    
21    print("This program uses \"The Sieve of Eratosthenes\" for finding prime numbers.\n\n")
22    high = uint( congetstr("Enter the high limit number ( < 100000 ): ", input ))
23    if high > 100000 : high = 100000
24 	
25    arr  sieve[ high + 1 ] of byte
26    
27    fornum i = 2, high/2 + 1
28    {
29       if !sieve[ i ]
30       {
31          j = i + i
32          while j <= high
33          {
34             sieve[ j ] = 1
35             j += i
36          }
37       }
38    }
39    j = 0
40    input.setlen( 0 )
41 
42    fornum i = 2, high + 1
43    {
44       if !sieve[ i ]
45       {
46          input.out4( "%8u", i )
47          if ++j == 10 
48          {
49             j = 0
50             input += "\l"
51          }
52       }
53    }
54 
55    input.write( "prime.txt" )
56    shell( "prime.txt" )
57 }
58