Largest proper divisor of n: Difference between revisions

Grouping BASIC dialects
(add RPL)
(Grouping BASIC dialects)
Line 503:
</syntaxhighlight>
{{out}}
<pre> 1 1 1 2 1 3 1 4 3 5
<pre>
1 1 1 2 1 3 1 4 3 5
1 6 1 7 5 8 1 9 1 10
7 11 1 12 5 13 9 14 1 15
Line 515 ⟶ 514:
13 46 31 47 19 48 1 49 33 50
 
Largest proper divisor of n 1-100</pre>
</pre>
 
=={{header|BASIC}}==
{{works with|QBasic|1.1}}
{{works with|QuickBasic|4.5}}
<syntaxhighlight lang="basic">10 DEFINT A-Z
20 FOR I=1 TO 100
Line 539:
13 46 31 47 19 48 1 49 33 50</pre>
 
==={{header|BASIC256}}===
{{trans|FreeBASIC}}
<syntaxhighlight lang="basic256">print "El mayor divisor propio de n es:\n"
Line 554:
end</syntaxhighlight>
 
==={{header|FreeBASIC}}===
<syntaxhighlight lang="freebasic">Print !"El mayor divisor propio de n es:\n"
Print " 1 1";
For i As Byte = 3 To 100
For j As Byte = i-1 To 1 Step -1
If i Mod j = 0 Then Print Using "###"; j; : Exit For
Next j
If i Mod 10 = 0 Then Print
Next i
Sleep</syntaxhighlight>
{{out}}
<pre>El mayor divisor propio de n es:
 
1 1 1 2 1 3 1 4 3 5
1 6 1 7 5 8 1 9 1 10
7 11 1 12 5 13 9 14 1 15
1 16 11 17 7 18 1 19 13 20
1 21 1 22 15 23 1 24 7 25
17 26 1 27 11 28 19 29 1 30
1 31 21 32 13 33 1 34 23 35
1 36 1 37 25 38 11 39 1 40
27 41 1 42 17 43 29 44 1 45
13 46 31 47 19 48 1 49 33 50</pre>
 
==={{header|FutureBasic}}===
<syntaxhighlight lang="futurebasic">NSUInteger i, j
 
print " 1 1";
for i = 3 to 100
for j = i - 1 to 1 step - 1
if i mod j = 0 then print using "###"; j; : exit for
next
if i mod 10 = 0 then print
next
 
HandleEvents</syntaxhighlight>
{{output}}
<pre> 1 1 1 2 1 3 1 4 3 5
1 6 1 7 5 8 1 9 1 10
7 11 1 12 5 13 9 14 1 15
1 16 11 17 7 18 1 19 13 20
1 21 1 22 15 23 1 24 7 25
17 26 1 27 11 28 19 29 1 30
1 31 21 32 13 33 1 34 23 35
1 36 1 37 25 38 11 39 1 40
27 41 1 42 17 43 29 44 1 45
13 46 31 47 19 48 1 49 33 50</pre>
 
==={{header|GW-BASIC}}===
<syntaxhighlight lang="gwbasic">10 PRINT 1;
20 FOR I = 1 TO 101
30 FOR D = I\2 TO 1 STEP -1
40 IF I MOD D = 0 THEN PRINT D; : GOTO 60
50 NEXT D
60 NEXT I</syntaxhighlight>
 
==={{header|PureBasic}}===
<syntaxhighlight lang="purebasic">Procedure.i lpd(v.i)
For i=v/2 To 1 Step -1
If v%i=0 : ProcedureReturn i : EndIf
Next
ProcedureReturn 1
EndProcedure
 
If OpenConsole("")
For i=1 To 100
Print(RSet(Str(lpd(i)),3))
If i%10=0 : PrintN("") : EndIf
Next
Input()
EndIf</syntaxhighlight>
{{out}}
<pre> 1 1 1 2 1 3 1 4 3 5
1 6 1 7 5 8 1 9 1 10
7 11 1 12 5 13 9 14 1 15
1 16 11 17 7 18 1 19 13 20
1 21 1 22 15 23 1 24 7 25
17 26 1 27 11 28 19 29 1 30
1 31 21 32 13 33 1 34 23 35
1 36 1 37 25 38 11 39 1 40
27 41 1 42 17 43 29 44 1 45
13 46 31 47 19 48 1 49 33 50</pre>
 
==={{header|True BASIC}}===
{{trans|FreeBASIC}}
<syntaxhighlight lang="qbasic">PRINT "El mayor divisor propio de n es:"
PRINT
PRINT " 1 1";
FOR i = 3 To 100
FOR j = i-1 To 1 Step -1
IF remainder(i, j) = 0 Then
PRINT Using$("###", j);
EXIT FOR
END IF
NEXT j
IF remainder(i, 10) = 0 Then PRINT
NEXT i
END</syntaxhighlight>
{{out}}
<pre>Same as FreeBASIC entry.</pre>
 
==={{header|Yabasic}}===
{{trans|FreeBASIC}}
<syntaxhighlight lang="yabasic">print "El mayor divisor propio de n es:\n"
print " 1 1 ";
for i = 3 to 100
for j = i-1 to 1 step -1
If mod(i, j) = 0 then print j using "##"; : break : fi
next j
if mod(i, 10) = 0 then print : fi
next i
print
end</syntaxhighlight>
{{out}}
<pre>Same as FreeBASIC entry.</pre>
 
=={{header|BCPL}}==
Line 936 ⟶ 1,051:
{{out}}
<pre> 1 1 1 2 1 3 1 4 3 5
1 6 1 7 5 8 1 9 1 10
7 11 1 12 5 13 9 14 1 15
1 16 11 17 7 18 1 19 13 20
1 21 1 22 15 23 1 24 7 25
17 26 1 27 11 28 19 29 1 30
1 31 21 32 13 33 1 34 23 35
1 36 1 37 25 38 11 39 1 40
27 41 1 42 17 43 29 44 1 45
13 46 31 47 19 48 1 49 33 50</pre>
 
 
=={{header|FreeBASIC}}==
<syntaxhighlight lang="freebasic">Print !"El mayor divisor propio de n es:\n"
Print " 1 1";
For i As Byte = 3 To 100
For j As Byte = i-1 To 1 Step -1
If i Mod j = 0 Then Print Using "###"; j; : Exit For
Next j
If i Mod 10 = 0 Then Print
Next i
Sleep</syntaxhighlight>
{{out}}
<pre>El mayor divisor propio de n es:
 
1 1 1 2 1 3 1 4 3 5
1 6 1 7 5 8 1 9 1 10
7 11 1 12 5 13 9 14 1 15
Line 976 ⟶ 1,066:
<syntaxhighlight lang="frink">for n = 1 to 100
println[last[allFactors[n,true,false]]]</syntaxhighlight>
 
 
 
=={{header|FutureBasic}}==
<syntaxhighlight lang="futurebasic">
NSUInteger i, j
 
print " 1 1";
for i = 3 to 100
for j = i - 1 to 1 step - 1
if i mod j = 0 then print using "###"; j; : exit for
next
if i mod 10 = 0 then print
next
 
HandleEvents
</syntaxhighlight>
{{output}}
<pre>
1 1 1 2 1 3 1 4 3 5
1 6 1 7 5 8 1 9 1 10
7 11 1 12 5 13 9 14 1 15
1 16 11 17 7 18 1 19 13 20
1 21 1 22 15 23 1 24 7 25
17 26 1 27 11 28 19 29 1 30
1 31 21 32 13 33 1 34 23 35
1 36 1 37 25 38 11 39 1 40
27 41 1 42 17 43 29 44 1 45
13 46 31 47 19 48 1 49 33 50
</pre>
 
 
=={{header|Go}}==
Line 1,051 ⟶ 1,110:
13 46 31 47 19 48 1 49 33 50
</pre>
 
 
 
 
 
 
=={{header|GW-BASIC}}==
<syntaxhighlight lang="gwbasic">10 PRINT 1;
20 FOR I = 1 TO 101
30 FOR D = I\2 TO 1 STEP -1
40 IF I MOD D = 0 THEN PRINT D; : GOTO 60
50 NEXT D
60 NEXT I</syntaxhighlight>
 
=={{header|Haskell}}==
Line 1,497 ⟶ 1,543:
CALL EXIT;
EOF</syntaxhighlight>
{{out}}
<pre> 1 1 1 2 1 3 1 4 3 5
1 6 1 7 5 8 1 9 1 10
7 11 1 12 5 13 9 14 1 15
1 16 11 17 7 18 1 19 13 20
1 21 1 22 15 23 1 24 7 25
17 26 1 27 11 28 19 29 1 30
1 31 21 32 13 33 1 34 23 35
1 36 1 37 25 38 11 39 1 40
27 41 1 42 17 43 29 44 1 45
13 46 31 47 19 48 1 49 33 50</pre>
 
=={{header|PureBasic}}==
<syntaxhighlight lang="purebasic">Procedure.i lpd(v.i)
For i=v/2 To 1 Step -1
If v%i=0 : ProcedureReturn i : EndIf
Next
ProcedureReturn 1
EndProcedure
 
If OpenConsole("")
For i=1 To 100
Print(RSet(Str(lpd(i)),3))
If i%10=0 : PrintN("") : EndIf
Next
Input()
EndIf</syntaxhighlight>
{{out}}
<pre> 1 1 1 2 1 3 1 4 3 5
Line 2,030 ⟶ 2,049:
end subroutine
|}
 
=={{header|True BASIC}}==
{{trans|FreeBASIC}}
<syntaxhighlight lang="qbasic">PRINT "El mayor divisor propio de n es:"
PRINT
PRINT " 1 1";
FOR i = 3 To 100
FOR j = i-1 To 1 Step -1
IF remainder(i, j) = 0 Then
PRINT Using$("###", j);
EXIT FOR
END IF
NEXT j
IF remainder(i, 10) = 0 Then PRINT
NEXT i
END</syntaxhighlight>
{{out}}
<pre>
Igual que la entrada de FreeBASIC.
</pre>
 
=={{header|V (Vlang)}}==
Line 2,110 ⟶ 2,109:
 
{{out}}
<pre>The largest proper divisors for numbers in the interval [1, 100] are:
<pre>
The largest proper divisors for numbers in the interval [1, 100] are:
1 1 1 2 1 3 1 4 3 5
1 6 1 7 5 8 1 9 1 10
Line 2,121 ⟶ 2,119:
1 36 1 37 25 38 11 39 1 40
27 41 1 42 17 43 29 44 1 45
13 46 31 47 19 48 1 49 33 50 </pre>
</pre>
 
 
=={{header|Yabasic}}==
{{trans|FreeBASIC}}
<syntaxhighlight lang="yabasic">print "El mayor divisor propio de n es:\n"
print " 1 1 ";
for i = 3 to 100
for j = i-1 to 1 step -1
If mod(i, j) = 0 then print j using "##"; : break : fi
next j
if mod(i, 10) = 0 then print : fi
next i
print
end</syntaxhighlight>
{{out}}
<pre>
Igual que la entrada de FreeBASIC.
</pre>
 
 
=={{header|X86 Assembly}}==
2,169

edits