<?xml version="1.0" encoding="utf-8"?>
<rss version="2.0">
<channel>
<title>Programming &amp; Software Q&amp;A | CollectiveSolver - Recent questions and answers</title>
<link>https://collectivesolver.com/qa</link>
<description>Powered by Question2Answer</description>
<item>
<title>Answered: How to find A and B where A and B are prime numbers and A * B = 12349 in C#</title>
<link>https://collectivesolver.com/98176/how-to-find-a-and-b-where-a-and-b-are-prime-numbers-and-a-b-12349-in-c%23?show=98177#a98177</link>
<description>&lt;pre class=&quot;brush:csharp;&quot;&gt;using System;

public class FindABProgram
{
    // Function to check if a number is prime
    static bool isPrime(int n)
    {
        if (n &amp;lt;= 1) return false;
        if (n &amp;lt;= 3) return true;
        if (n % 2 == 0 || n % 3 == 0) return false;

        int limit = (int)Math.Sqrt(n);
        for (int i = 5; i &amp;lt;= limit; i += 6) {
            if (n % i == 0 || n % (i + 2) == 0)
                return false;
        }

        return true;
    }

    // Helper class to return A and B together
    class Pair
    {
        public int A, B;
        public Pair(int A, int B)
        {
            this.A = A;
            this.B = B;
        }
    }

    // Function to find the two prime factors A and B
    static Pair findAB(int N)
    {
        int limit = (int)Math.Sqrt(N);

        for (int i = 2; i &amp;lt;= limit; i++) {
            if (N % i == 0) {
                int j = N / i;
                if (isPrime(i) &amp;amp;&amp;amp; isPrime(j)) {
                    return new Pair(i, j);
                }
            }
        }

        return new Pair(-1, -1); // No prime factors found
    }

    public static void Main(string[] args)
    {
        int N = 12349;

        Pair result = findAB(N);

        if (result.A != -1)
            Console.WriteLine(&quot;A = &quot; + result.A + &quot;, B = &quot; + result.B);
        else
            Console.WriteLine(&quot;Not found.&quot;);
    }
}



/*
run:

A = 53, B = 233

*/
&lt;/pre&gt;&lt;p&gt;&amp;nbsp;&lt;/p&gt;</description>
<guid isPermaLink="true">https://collectivesolver.com/98176/how-to-find-a-and-b-where-a-and-b-are-prime-numbers-and-a-b-12349-in-c%23?show=98177#a98177</guid>
<pubDate>Fri, 05 Jun 2026 15:45:45 +0000</pubDate>
</item>
<item>
<title>Answered: How to find A and B where A and B are prime numbers and A * B = 12349 in VB.NET</title>
<link>https://collectivesolver.com/98174/how-to-find-a-and-b-where-a-and-b-are-prime-numbers-and-a-b-12349-in-vb-net?show=98175#a98175</link>
<description>&lt;pre class=&quot;brush:vb;&quot;&gt;Imports System

Module FindABProgram

    ' Function to check if a number is prime
    Function isPrime(n As Integer) As Boolean
        If n &amp;lt;= 1 Then Return False
        If n &amp;lt;= 3 Then Return True
        If (n Mod 2 = 0) OrElse (n Mod 3 = 0) Then Return False

        Dim limit As Integer = CInt(Math.Sqrt(n))
        Dim i As Integer = 5

        While i &amp;lt;= limit
            If (n Mod i = 0) OrElse (n Mod (i + 2) = 0) Then
                Return False
            End If
            i += 6
        End While

        Return True
    End Function

    ' Function to find the two prime factors A and B
    Sub findAB(N As Integer, ByRef A As Integer, ByRef B As Integer)
        Dim limit As Integer = CInt(Math.Sqrt(N))

        For i As Integer = 2 To limit
            If N Mod i = 0 Then
                Dim j As Integer = N \ i
                If isPrime(i) AndAlso isPrime(j) Then
                    A = i
                    B = j
                    Exit Sub
                End If
            End If
        Next

        A = -1
        B = -1 ' No prime factors found
    End Sub

    Sub Main()
        Dim N As Integer = 12349
        Dim A As Integer
        Dim B As Integer

        findAB(N, A, B)

        If A &amp;lt;&amp;gt; -1 Then
            Console.WriteLine(&quot;A = &quot; &amp;amp; A &amp;amp; &quot;, B = &quot; &amp;amp; B)
        Else
            Console.WriteLine(&quot;Not found.&quot;)
        End If
    End Sub

End Module

			

' run:
'
' A = 53, B = 233
'
&lt;/pre&gt;&lt;p&gt;&amp;nbsp;&lt;/p&gt;</description>
<guid isPermaLink="true">https://collectivesolver.com/98174/how-to-find-a-and-b-where-a-and-b-are-prime-numbers-and-a-b-12349-in-vb-net?show=98175#a98175</guid>
<pubDate>Fri, 05 Jun 2026 15:13:29 +0000</pubDate>
</item>
<item>
<title>Answered: How to find A and B where A and B are prime numbers and A * B = 12349 in Java</title>
<link>https://collectivesolver.com/98172/how-to-find-a-and-b-where-a-and-b-are-prime-numbers-and-a-b-12349-in-java?show=98173#a98173</link>
<description>&lt;pre class=&quot;brush:java;&quot;&gt;import java.lang.Math;

public class FindABProgram {

    // Function to check if a number is prime
    static boolean isPrime(int n) {
        if (n &amp;lt;= 1) return false;
        if (n &amp;lt;= 3) return true;
        if (n % 2 == 0 || n % 3 == 0) return false;

        int limit = (int)Math.sqrt(n);
        for (int i = 5; i &amp;lt;= limit; i += 6) {
            if (n % i == 0 || n % (i + 2) == 0)
                return false;
        }

        return true;
    }

    // Helper class to return A and B together
    static class Pair {
        int A, B;
        Pair(int A, int B) { this.A = A; this.B = B; }
    }

    // Function to find the two prime factors A and B
    static Pair findAB(int N) {
        int limit = (int)Math.sqrt(N);

        for (int i = 2; i &amp;lt;= limit; i++) {
            if (N % i == 0) {
                int j = N / i;
                if (isPrime(i) &amp;amp;&amp;amp; isPrime(j)) {
                    return new Pair(i, j);
                }
            }
        }

        return new Pair(-1, -1); // No prime factors found
    }

    public static void main(String[] args) {
        int N = 12349;

        Pair result = findAB(N);

        if (result.A != -1)
            System.out.println(&quot;A = &quot; + result.A + &quot;, B = &quot; + result.B);
        else
            System.out.println(&quot;Not found.&quot;);
    }
}


/*
run:

A = 53, B = 233

*/
&lt;/pre&gt;&lt;p&gt;&amp;nbsp;&lt;/p&gt;</description>
<guid isPermaLink="true">https://collectivesolver.com/98172/how-to-find-a-and-b-where-a-and-b-are-prime-numbers-and-a-b-12349-in-java?show=98173#a98173</guid>
<pubDate>Fri, 05 Jun 2026 13:56:23 +0000</pubDate>
</item>
<item>
<title>Answered: How to find A and B where A and B are prime numbers and A * B = 12349 in Pascal</title>
<link>https://collectivesolver.com/98170/how-to-find-a-and-b-where-a-and-b-are-prime-numbers-and-a-b-12349-in-pascal?show=98171#a98171</link>
<description>&lt;pre class=&quot;brush:delphi;&quot;&gt;program FindABProgram;

{$mode objfpc}

uses
  Math;

// Function to check if a number is prime
function isPrime(n: Integer): Boolean;
var
  limit, i: Integer;
begin
  if n &amp;lt;= 1 then Exit(False);
  if n &amp;lt;= 3 then Exit(True);
  if (n mod 2 = 0) or (n mod 3 = 0) then Exit(False);

  limit := Trunc(Sqrt(n));
  i := 5;
  while i &amp;lt;= limit do
  begin
    if (n mod i = 0) or (n mod (i + 2) = 0) then
      Exit(False);
    Inc(i, 6);
  end;

  Result := True;
end;

// Function to find the two prime factors A and B
procedure findAB(N: Integer; var A, B: Integer);
var
  limit, i, j: Integer;
begin
  limit := Trunc(Sqrt(N));  

  for i := 2 to limit do
  begin
    if (N mod i = 0) then
    begin
      j := N div i;
      if isPrime(i) and isPrime(j) then
      begin
        A := i;
        B := j;
        Exit;
      end;
    end;
  end;

  A := -1;
  B := -1; // No prime factors found
end;

var
  N, A, B: Integer;

begin
  N := 12349;

  findAB(N, A, B);

  if A &amp;lt;&amp;gt; -1 then
    WriteLn('A = ', A, ', B = ', B)
  else
    WriteLn('Not found.');
end.



(*
run:

A = 53, B = 233

*)
&lt;/pre&gt;&lt;p&gt;&amp;nbsp;&lt;/p&gt;</description>
<guid isPermaLink="true">https://collectivesolver.com/98170/how-to-find-a-and-b-where-a-and-b-are-prime-numbers-and-a-b-12349-in-pascal?show=98171#a98171</guid>
<pubDate>Fri, 05 Jun 2026 13:39:35 +0000</pubDate>
</item>
<item>
<title>Answered: How to find A and B where A and B are prime numbers and A * B = 12349 in C</title>
<link>https://collectivesolver.com/98168/how-to-find-a-and-b-where-a-and-b-are-prime-numbers-and-a-b-12349-in-c?show=98169#a98169</link>
<description>&lt;pre class=&quot;brush:cpp;&quot;&gt;#include &amp;lt;stdio.h&amp;gt;
#include &amp;lt;math.h&amp;gt;

// Function to check if a number is prime
int isPrime(int n) {
    if (n &amp;lt;= 1) return 0;
    if (n &amp;lt;= 3) return 1;
    if (n % 2 == 0 || n % 3 == 0) return 0;

    int limit = (int)sqrt(n);
    for (int i = 5; i &amp;lt;= limit; i += 6) {
        if (n % i == 0 || n % (i + 2) == 0)
            return 0;
    }
    
    return 1;
}

// Function to find the two prime factors A and B
void findAB(int N, int *A, int *B) {
    int limit = (int)sqrt(N);   

    for (int i = 2; i &amp;lt;= limit; i++) {
        if (N % i == 0) {
            int j = N / i;
            if (isPrime(i) &amp;amp;&amp;amp; isPrime(j)) {
                *A = i;
                *B = j;
                return;
            }
        }
    }

    *A = *B = -1; // No prime factors found
}

int main() {
    int N = 12349;
    int A, B;

    findAB(N, &amp;amp;A, &amp;amp;B);

    if (A != -1)
        printf(&quot;A = %d, B = %d\n&quot;, A, B);
    else
        printf(&quot;Not found.\n&quot;);

    return 0;
}


/*
run:

A = 53, B = 233

*/
&lt;/pre&gt;&lt;p&gt;&amp;nbsp;&lt;/p&gt;</description>
<guid isPermaLink="true">https://collectivesolver.com/98168/how-to-find-a-and-b-where-a-and-b-are-prime-numbers-and-a-b-12349-in-c?show=98169#a98169</guid>
<pubDate>Fri, 05 Jun 2026 09:23:19 +0000</pubDate>
</item>
<item>
<title>Answered: How to find A and B where A and B are prime numbers and A * B = 12349 in C++</title>
<link>https://collectivesolver.com/98166/how-to-find-a-and-b-where-a-and-b-are-prime-numbers-and-a-b-12349-in-c?show=98167#a98167</link>
<description>&lt;pre class=&quot;brush:cpp;&quot;&gt;#include &amp;lt;iostream&amp;gt;
#include &amp;lt;cmath&amp;gt;

// Function to check if a number is prime
bool isPrime(int n) {
    if (n &amp;lt;= 1) return false;
    if (n &amp;lt;= 3) return true;
    if (n % 2 == 0 || n % 3 == 0) return false;

    int limit = sqrt(n);
    for (int i = 5; i &amp;lt;= limit; i += 6) {
        if (n % i == 0 || n % (i + 2) == 0)
            return false;
    }
    
    return true;
}

// Function to find the two prime factors A and B
void findAB(int N, int &amp;amp;A, int &amp;amp;B) {
    int limit = sqrt(N);  

    for (int i = 2; i &amp;lt;= limit; i++) {
        if (N % i == 0) {
            int j = N / i;
            if (isPrime(i) &amp;amp;&amp;amp; isPrime(j)) {
                A = i;
                B = j;
                return;
            }
        }
    }

    A = B = -1; // No prime factors found
}

int main() {
    int N = 12349;
    int A, B;

    findAB(N, A, B);

    if (A != -1)
        std::cout &amp;lt;&amp;lt; &quot;A = &quot; &amp;lt;&amp;lt; A &amp;lt;&amp;lt; &quot;, B = &quot; &amp;lt;&amp;lt; B &amp;lt;&amp;lt; std::endl;
    else
        std::cout &amp;lt;&amp;lt; &quot;Not found.&quot; &amp;lt;&amp;lt; std::endl;
}



/*
run:

A = 53, B = 233

*/&lt;/pre&gt;&lt;p&gt;&amp;nbsp;&lt;/p&gt;</description>
<guid isPermaLink="true">https://collectivesolver.com/98166/how-to-find-a-and-b-where-a-and-b-are-prime-numbers-and-a-b-12349-in-c?show=98167#a98167</guid>
<pubDate>Fri, 05 Jun 2026 09:14:09 +0000</pubDate>
</item>
<item>
<title>Answered: How to create 10 random points in C++</title>
<link>https://collectivesolver.com/98160/how-to-create-10-random-points-in-c?show=98165#a98165</link>
<description>&lt;pre class=&quot;brush:cpp;&quot;&gt;#include &amp;lt;iostream&amp;gt;
#include &amp;lt;random&amp;gt;
#include &amp;lt;vector&amp;gt;

struct Point {
    int x;
    int y;
};

// Generate one random point in [10, 90]
Point generatePoint(std::mt19937&amp;amp; gen, std::uniform_int_distribution&amp;lt;int&amp;gt;&amp;amp; dist) {
    return Point{ dist(gen), dist(gen) };
}

int main() {
    std::random_device rd;
    std::mt19937 gen(rd());
    std::uniform_int_distribution&amp;lt;int&amp;gt; dist(10, 90);

    std::vector&amp;lt;Point&amp;gt; points;

    for (int i = 0; i &amp;lt; 10; ++i) {
        points.push_back(generatePoint(gen, dist));
    }

    for (int i = 0; i &amp;lt; points.size(); i++) {
        std::cout &amp;lt;&amp;lt; &quot;Point &quot; &amp;lt;&amp;lt; i + 1 &amp;lt;&amp;lt; &quot;: (&quot;
                  &amp;lt;&amp;lt; points[i].x &amp;lt;&amp;lt; &quot;, &quot; &amp;lt;&amp;lt; points[i].y &amp;lt;&amp;lt; &quot;)\n&quot;;
    }
}



/*
run:

Point 1: (54, 25)
Point 2: (26, 40)
Point 3: (47, 41)
Point 4: (20, 33)
Point 5: (72, 36)
Point 6: (10, 85)
Point 7: (80, 65)
Point 8: (80, 82)
Point 9: (44, 43)
Point 10: (22, 81)

*/&lt;/pre&gt;&lt;p&gt;&amp;nbsp;&lt;/p&gt;</description>
<guid isPermaLink="true">https://collectivesolver.com/98160/how-to-create-10-random-points-in-c?show=98165#a98165</guid>
<pubDate>Fri, 05 Jun 2026 08:31:59 +0000</pubDate>
</item>
<item>
<title>Answered: How to create 10 random points in C</title>
<link>https://collectivesolver.com/98162/how-to-create-10-random-points-in-c?show=98164#a98164</link>
<description>&lt;pre class=&quot;brush:cpp;&quot;&gt;#include &amp;lt;stdio.h&amp;gt;
#include &amp;lt;stdlib.h&amp;gt;
#include &amp;lt;time.h&amp;gt;

typedef struct {
    int x;
    int y;
} Point;

// Generate one random point in [10, 90]
Point generatePoint() {
    Point p;
    p.x = rand() % 81 + 10;  // 10–90
    p.y = rand() % 81 + 10;  // 10–90
    return p;
}

int main() {
    srand(time(NULL));  // Seed RNG

    Point points[10];

    for (int i = 0; i &amp;lt; 10; i++) {
        points[i] = generatePoint();
    }

    for (int i = 0; i &amp;lt; 10; i++) {
        printf(&quot;Point %d: (%d, %d)\n&quot;, i + 1, points[i].x, points[i].y);
    }

    return 0;
}



/*
run:

Point 1: (49, 66)
Point 2: (47, 52)
Point 3: (80, 57)
Point 4: (62, 36)
Point 5: (66, 10)
Point 6: (40, 62)
Point 7: (64, 22)
Point 8: (16, 82)
Point 9: (89, 63)
Point 10: (56, 37)

*/&lt;/pre&gt;&lt;p&gt;&amp;nbsp;&lt;/p&gt;</description>
<guid isPermaLink="true">https://collectivesolver.com/98162/how-to-create-10-random-points-in-c?show=98164#a98164</guid>
<pubDate>Fri, 05 Jun 2026 08:30:25 +0000</pubDate>
</item>
<item>
<title>Answered: How to create a first-class function in C++</title>
<link>https://collectivesolver.com/98158/how-to-create-a-first-class-function-in-c?show=98159#a98159</link>
<description>&lt;pre class=&quot;brush:cpp;&quot;&gt;#include &amp;lt;iostream&amp;gt;
#include &amp;lt;functional&amp;gt;   // std::function

// What a first‑class function does:
// It can be stored in a variable
// It can be passed to another function
// It can be returned from a function
// It can capture variables (if it’s a lambda)
// It allows dynamic behavior

// A first‑class function in C++ is created by treating a function as a value
// something you can store in a variable, pass to another function, or return from a function.
// In modern C++, the cleanest way to do this is with std::function, function pointers, or lambdas.

// A normal function
int add(int a, int b) {
    return a + b;
}

// A function that *accepts* a first-class function
// std::function&amp;lt;int(int,int)&amp;gt; means: a callable taking (int,int) → int
void applyOperation(const std::function&amp;lt;int(int,int)&amp;gt;&amp;amp; op) {
    std::cout &amp;lt;&amp;lt; &quot;Result: &quot; &amp;lt;&amp;lt; op(10, 5) &amp;lt;&amp;lt; std::endl;
}

// A function that *returns* a first-class function
std::function&amp;lt;int(int,int)&amp;gt; getMultiplier(int factor) {
    // Return a lambda that captures 'factor'
    return [factor](int a, int b) {
        return factor * (a + b);
    };
}

int main() {
    // 1. Store a normal function as a first-class function
    std::function&amp;lt;int(int,int)&amp;gt; f1 = add;
    std::cout &amp;lt;&amp;lt; &quot;add(3,4) = &quot; &amp;lt;&amp;lt; f1(3,4) &amp;lt;&amp;lt; std::endl;

    // 2. Store a lambda as a first-class function
    std::function&amp;lt;int(int,int)&amp;gt; f2 = [](int a, int b) {
        return a * b;
    };
    std::cout &amp;lt;&amp;lt; &quot;lambda multiply = &quot; &amp;lt;&amp;lt; f2(3,4) &amp;lt;&amp;lt; std::endl;

    // 3. Pass a first-class function to another function
    applyOperation(add);      // passing normal function
    applyOperation(f2);       // passing lambda

    // 4. Return a first-class function from a function
    auto tripleAdder = getMultiplier(3);
    std::cout &amp;lt;&amp;lt; &quot;tripleAdder(2,3) = &quot; &amp;lt;&amp;lt; tripleAdder(2,3) &amp;lt;&amp;lt; std::endl;
}


/*
run:

add(3,4) = 7
lambda multiply = 12
Result: 15
Result: 50
tripleAdder(2,3) = 15

*/&lt;/pre&gt;&lt;p&gt;&amp;nbsp;&lt;/p&gt;</description>
<guid isPermaLink="true">https://collectivesolver.com/98158/how-to-create-a-first-class-function-in-c?show=98159#a98159</guid>
<pubDate>Fri, 05 Jun 2026 07:33:06 +0000</pubDate>
</item>
<item>
<title>Answered: How to represent the ABCs as a 5-letter binary code using A for 0 and B for 1 in PHP</title>
<link>https://collectivesolver.com/98156/how-to-represent-the-abcs-as-a-5-letter-binary-code-using-a-for-0-and-b-for-1-in-php?show=98157#a98157</link>
<description>&lt;pre class=&quot;brush:php;&quot;&gt;// a = AAAAA -&amp;gt; 00000 -&amp;gt; 0
// b = AAAAB -&amp;gt; 00001 -&amp;gt; 1
// c = AAABA -&amp;gt; 00010 -&amp;gt; 2
// d = AAABB -&amp;gt; 00011 -&amp;gt; 3
// e = AABAA -&amp;gt; 00100 -&amp;gt; 4
// f = AABAB -&amp;gt; 00101 -&amp;gt; 5
// g = AABBA -&amp;gt; 00110 -&amp;gt; 6

// Convert integer n (0–31) into 5-letter A/B code
function toAB($n) {
    $out = &quot;&quot;;

    for ($i = 4; $i &amp;gt;= 0; $i--) {
        $bit = ($n &amp;gt;&amp;gt; $i) &amp;amp; 1;   // extract bit
        $out .= ($bit == 1 ? 'B' : 'A');
    }

    return $out;
}

for ($ch = ord('a'); $ch &amp;lt;= ord('z'); $ch++) {
    $char = chr($ch);
    $value = $ch - ord('a');      // a=0, b=1, c=2...
    $code = toAB($value);

    echo $char . &quot; -&amp;gt; &quot; . $value . &quot; -&amp;gt; &quot; . $code . &quot;\n&quot;;
}


/*
run:

a -&amp;gt; 0 -&amp;gt; AAAAA
b -&amp;gt; 1 -&amp;gt; AAAAB
c -&amp;gt; 2 -&amp;gt; AAABA
d -&amp;gt; 3 -&amp;gt; AAABB
e -&amp;gt; 4 -&amp;gt; AABAA
f -&amp;gt; 5 -&amp;gt; AABAB
g -&amp;gt; 6 -&amp;gt; AABBA
h -&amp;gt; 7 -&amp;gt; AABBB
i -&amp;gt; 8 -&amp;gt; ABAAA
j -&amp;gt; 9 -&amp;gt; ABAAB
k -&amp;gt; 10 -&amp;gt; ABABA
l -&amp;gt; 11 -&amp;gt; ABABB
m -&amp;gt; 12 -&amp;gt; ABBAA
n -&amp;gt; 13 -&amp;gt; ABBAB
o -&amp;gt; 14 -&amp;gt; ABBBA
p -&amp;gt; 15 -&amp;gt; ABBBB
q -&amp;gt; 16 -&amp;gt; BAAAA
r -&amp;gt; 17 -&amp;gt; BAAAB
s -&amp;gt; 18 -&amp;gt; BAABA
t -&amp;gt; 19 -&amp;gt; BAABB
u -&amp;gt; 20 -&amp;gt; BABAA
v -&amp;gt; 21 -&amp;gt; BABAB
w -&amp;gt; 22 -&amp;gt; BABBA
x -&amp;gt; 23 -&amp;gt; BABBB
y -&amp;gt; 24 -&amp;gt; BBAAA
z -&amp;gt; 25 -&amp;gt; BBAAB

*/

&lt;/pre&gt;&lt;p&gt;&amp;nbsp;&lt;/p&gt;</description>
<guid isPermaLink="true">https://collectivesolver.com/98156/how-to-represent-the-abcs-as-a-5-letter-binary-code-using-a-for-0-and-b-for-1-in-php?show=98157#a98157</guid>
<pubDate>Fri, 05 Jun 2026 07:08:53 +0000</pubDate>
</item>
<item>
<title>Answered: How to write a multiple‑choice question implemented in COBOL</title>
<link>https://collectivesolver.com/98154/how-to-write-a-multiple-choice-question-implemented-in-cobol?show=98155#a98155</link>
<description>&lt;pre class=&quot;brush:python;&quot;&gt;       IDENTIFICATION DIVISION.
       PROGRAM-ID. MCQ-COBOL.

       DATA DIVISION.
       WORKING-STORAGE SECTION.
       01 USER-ANSWER PIC A(1).        *&amp;gt; Stores the user's choice

       PROCEDURE DIVISION.
           DISPLAY &quot;Multiple-Choice Question:&quot;
           DISPLAY &quot;What does COBOL stand for?&quot;
           DISPLAY &quot;A. Common Business-Oriented Language&quot;
           DISPLAY &quot;B. Computer Binary Operating Logic&quot;
           DISPLAY &quot;C. Central Business Operations Layer&quot;
           DISPLAY &quot;D. Code Base Optimization Language&quot;
           DISPLAY &quot; &quot;
           DISPLAY &quot;Enter your answer (A/B/C/D): &quot;
           ACCEPT USER-ANSWER

           IF USER-ANSWER = &quot;A&quot;
               DISPLAY &quot;Correct! COBOL means Common Business-Oriented Language.&quot;
           ELSE
               DISPLAY &quot;Incorrect. The correct answer is A.&quot;
           END-IF

           STOP RUN.



    *&amp;gt; run:
    *&amp;gt;
    *&amp;gt; Multiple-Choice Question:
    *&amp;gt; What does COBOL stand for?
    *&amp;gt; A. Common Business-Oriented Language
    *&amp;gt; B. Computer Binary Operating Logic
    *&amp;gt; C. Central Business Operations Layer
    *&amp;gt; D. Code Base Optimization Language
    *&amp;gt;
    *&amp;gt; Enter your answer (A/B/C/D): 
    *&amp;gt; A
    *&amp;gt; Correct! COBOL means Common Business-Oriented Language.
    *&amp;gt;&lt;/pre&gt;&lt;p&gt;&amp;nbsp;&lt;/p&gt;</description>
<guid isPermaLink="true">https://collectivesolver.com/98154/how-to-write-a-multiple-choice-question-implemented-in-cobol?show=98155#a98155</guid>
<pubDate>Fri, 05 Jun 2026 06:30:23 +0000</pubDate>
</item>
<item>
<title>Answered: How to input an age in COBOL</title>
<link>https://collectivesolver.com/98152/how-to-input-an-age-in-cobol?show=98153#a98153</link>
<description>&lt;pre class=&quot;brush:python;&quot;&gt;       IDENTIFICATION DIVISION.
       PROGRAM-ID. ASK-AGE.
       DATA DIVISION.
       WORKING-STORAGE SECTION.
       01 AGE PIC 99.
       PROCEDURE DIVISION.
           DISPLAY &quot;How old are you?&quot;
           ACCEPT AGE
           DISPLAY &quot;You are &quot; AGE &quot; years old.&quot;
           STOP RUN.

            
            
        *&amp;gt; run:
        *&amp;gt; 
        *&amp;gt; How old are you?
        *&amp;gt; 42
        *&amp;gt; You are 42 years old.
        *&amp;gt;
&lt;/pre&gt;&lt;p&gt;&amp;nbsp;&lt;/p&gt;</description>
<guid isPermaLink="true">https://collectivesolver.com/98152/how-to-input-an-age-in-cobol?show=98153#a98153</guid>
<pubDate>Thu, 04 Jun 2026 18:17:09 +0000</pubDate>
</item>
<item>
<title>Answered: How to input a name in COBOL</title>
<link>https://collectivesolver.com/98150/how-to-input-a-name-in-cobol?show=98151#a98151</link>
<description>&lt;pre class=&quot;brush:python;&quot;&gt;        IDENTIFICATION DIVISION.
        PROGRAM-ID. ASK-NAME.
        DATA DIVISION.
        WORKING-STORAGE SECTION.
        01 USER-NAME PIC A(20).
        PROCEDURE DIVISION.
            DISPLAY &quot;What is your name?&quot;        *&amp;gt; Question
            ACCEPT USER-NAME                    *&amp;gt; Read input
            DISPLAY &quot;Hello, &quot; USER-NAME &quot;!&quot;     *&amp;gt; Answer
            STOP RUN.
            
            
        *&amp;gt; run:
        *&amp;gt; 
        *&amp;gt; What is your name?
        *&amp;gt; Avi
        *&amp;gt; Hello, Avi 
        *&amp;gt;&lt;/pre&gt;&lt;p&gt;&amp;nbsp;&lt;/p&gt;</description>
<guid isPermaLink="true">https://collectivesolver.com/98150/how-to-input-a-name-in-cobol?show=98151#a98151</guid>
<pubDate>Thu, 04 Jun 2026 17:08:38 +0000</pubDate>
</item>
<item>
<title>Answered: How to use higher-order functions in Swift</title>
<link>https://collectivesolver.com/98147/how-to-use-higher-order-functions-in-swift?show=98149#a98149</link>
<description>&lt;pre class=&quot;brush:jscript;&quot;&gt;// A higher‑order function is a function that does at least one of the following:
// 1. Takes another function as an argument
// 2. Returns a function as its result
// If it does either one, it qualifies.

// makeMultiplier is a higher‑order function because it RETURNS another function
func makeMultiplier(_ n: Int) -&amp;gt; (Int) -&amp;gt; Int {

    // This inner function forms a closure and remembers the value of n
    return { x in
        return x * n // Uses the captured value n
    }
}

// double_val is now a function created by makeMultiplier(2)
// It remembers n = 2 through closure
let double_val = makeMultiplier(2)

// Calling double_val(10) multiplies 10 by the captured n (which is 2)
print(double_val(10))



/*
run:

20

*/
&lt;/pre&gt;&lt;p&gt;&amp;nbsp;&lt;/p&gt;</description>
<guid isPermaLink="true">https://collectivesolver.com/98147/how-to-use-higher-order-functions-in-swift?show=98149#a98149</guid>
<pubDate>Thu, 04 Jun 2026 15:30:43 +0000</pubDate>
</item>
<item>
<title>Answered: How to use higher-order functions in Kotlin</title>
<link>https://collectivesolver.com/98144/how-to-use-higher-order-functions-in-kotlin?show=98146#a98146</link>
<description>&lt;pre class=&quot;brush:jscript;&quot;&gt;// A higher‑order function is a function that does at least one of the following:
// 1. Takes another function as an argument
// 2. Returns a function as its result
// If it does either one, it qualifies.

// makeMultiplier is a higher‑order function because it RETURNS another function
fun makeMultiplier(n: Int): (Int) -&amp;gt; Int {

    // This inner function forms a closure and remembers the value of n
    return { x: Int -&amp;gt;
        x * n // Uses the captured value n
    }
}

fun main() {
    // double_val is now a function created by makeMultiplier(2)
    // It remembers n = 2 through closure
    val double_val = makeMultiplier(2)

    // Calling double_val(10) multiplies 10 by the captured n (which is 2)
    println(double_val(10))
}



/*
run:

20

*/
&lt;/pre&gt;&lt;p&gt;&amp;nbsp;&lt;/p&gt;</description>
<guid isPermaLink="true">https://collectivesolver.com/98144/how-to-use-higher-order-functions-in-kotlin?show=98146#a98146</guid>
<pubDate>Thu, 04 Jun 2026 15:25:06 +0000</pubDate>
</item>
<item>
<title>Answered: How to use higher-order functions in Scala</title>
<link>https://collectivesolver.com/98141/how-to-use-higher-order-functions-in-scala?show=98143#a98143</link>
<description>&lt;pre class=&quot;brush:scala;&quot;&gt;// A higher‑order function is a function that does at least one of the following:
// 1. Takes another function as an argument
// 2. Returns a function as its result
// If it does either one, it qualifies.

// makeMultiplier is a higher‑order function because it RETURNS another function
def makeMultiplier(n: Int): Int =&amp;gt; Int =

  // This inner function forms a closure and remembers the value of n
  (x: Int) =&amp;gt; x * n // Uses the captured value n

@main def runExample2(): Unit =
  // double_val is now a function created by makeMultiplier(2)
  // It remembers n = 2 through closure
  val double_val = makeMultiplier(2)

  // Calling double_val(10) multiplies 10 by the captured n (which is 2)
  println(double_val(10))
  
  

/*
run:

20

*/
&lt;/pre&gt;&lt;p&gt;&amp;nbsp;&lt;/p&gt;</description>
<guid isPermaLink="true">https://collectivesolver.com/98141/how-to-use-higher-order-functions-in-scala?show=98143#a98143</guid>
<pubDate>Thu, 04 Jun 2026 15:14:22 +0000</pubDate>
</item>
<item>
<title>Answered: How to use higher-order functions in Ruby</title>
<link>https://collectivesolver.com/98138/how-to-use-higher-order-functions-in-ruby?show=98140#a98140</link>
<description>&lt;pre class=&quot;brush:cpp;&quot;&gt;# A higher‑order function is a function that does at least one of the following:
# 1. Takes another function as an argument
# 2. Returns a function as its result
# If it does either one, it qualifies.

# makeMultiplier is a higher‑order function because it RETURNS another function
def make_multiplier(n)

  # This inner function forms a closure and remembers the value of n
  return -&amp;gt;(x) { x * n } # Uses the captured value n
end

# double_val is now a function created by makeMultiplier(2)
# It remembers n = 2 through closure
double_val = make_multiplier(2)

# Calling double_val(10) multiplies 10 by the captured n (which is 2)
puts double_val.call(10)



=begin
run:

20

=end
&lt;/pre&gt;&lt;p&gt;&amp;nbsp;&lt;/p&gt;</description>
<guid isPermaLink="true">https://collectivesolver.com/98138/how-to-use-higher-order-functions-in-ruby?show=98140#a98140</guid>
<pubDate>Thu, 04 Jun 2026 13:31:26 +0000</pubDate>
</item>
<item>
<title>Answered: How to use higher-order functions in Rust</title>
<link>https://collectivesolver.com/98135/how-to-use-higher-order-functions-in-rust?show=98137#a98137</link>
<description>&lt;pre class=&quot;brush:cpp;&quot;&gt;// A higher‑order function is a function that does at least one of the following:
// 1. Takes another function as an argument
// 2. Returns a function as its result
// If it does either one, it qualifies.

// makeMultiplier is a higher‑order function because it RETURNS another function
fn make_multiplier(n: i32) -&amp;gt; impl Fn(i32) -&amp;gt; i32 {

    // This inner function forms a closure and remembers the value of n
    move |x| x * n // Uses the captured value n
}

fn main() {
    // double_val is now a function created by makeMultiplier(2)
    // It remembers n = 2 through closure
    let double_val = make_multiplier(2);

    // Calling double_val(10) multiplies 10 by the captured n (which is 2)
    println!(&quot;{}&quot;, double_val(10));
}


/*
run:

20

*/
&lt;/pre&gt;&lt;p&gt;&amp;nbsp;&lt;/p&gt;</description>
<guid isPermaLink="true">https://collectivesolver.com/98135/how-to-use-higher-order-functions-in-rust?show=98137#a98137</guid>
<pubDate>Thu, 04 Jun 2026 09:47:10 +0000</pubDate>
</item>
<item>
<title>Answered: How to use higher-order functions in Go</title>
<link>https://collectivesolver.com/98132/how-to-use-higher-order-functions-in-go?show=98134#a98134</link>
<description>&lt;pre class=&quot;brush:cpp;&quot;&gt;package main

import &quot;fmt&quot;

// A higher‑order function is a function that does at least one of the following:
// 1. Takes another function as an argument
// 2. Returns a function as its result
// If it does either one, it qualifies.

// makeMultiplier is a higher‑order function because it RETURNS another function
func makeMultiplier(n int) func(int) int {

    // This inner function forms a closure and remembers the value of n
    return func(x int) int {
        return x * n // Uses the captured value n
    }
}

func main() {

    // double_val is now a function created by makeMultiplier(2)
    // It remembers n = 2 through closure
    double_val := makeMultiplier(2)

    // Calling double_val(10) multiplies 10 by the captured n (which is 2)
    fmt.Println(double_val(10))
}



/*
run:

20

*/
&lt;/pre&gt;&lt;p&gt;&amp;nbsp;&lt;/p&gt;</description>
<guid isPermaLink="true">https://collectivesolver.com/98132/how-to-use-higher-order-functions-in-go?show=98134#a98134</guid>
<pubDate>Thu, 04 Jun 2026 09:40:58 +0000</pubDate>
</item>
<item>
<title>Answered: How to use higher-order functions in Python</title>
<link>https://collectivesolver.com/98129/how-to-use-higher-order-functions-in-python?show=98131#a98131</link>
<description>&lt;pre class=&quot;brush:python;&quot;&gt;# A higher‑order function is a function that does at least one of the following:
# 1. Takes another function as an argument
# 2. Returns a function as its result
# If it does either one, it qualifies.

# makeMultiplier is a higher‑order function because it RETURNS another function
def makeMultiplier(n):

    # This inner function forms a closure and remembers the value of n
    def inner(x):
        return x * n  # Uses the captured value n

    return inner

# double_val is now a function created by makeMultiplier(2)
# It remembers n = 2 through closure
double_val = makeMultiplier(2)

# Calling double_val(10) multiplies 10 by the captured n (which is 2)
print(double_val(10))


&quot;&quot;&quot;
run:

20

&quot;&quot;&quot;
&lt;/pre&gt;&lt;p&gt;&amp;nbsp;&lt;/p&gt;</description>
<guid isPermaLink="true">https://collectivesolver.com/98129/how-to-use-higher-order-functions-in-python?show=98131#a98131</guid>
<pubDate>Thu, 04 Jun 2026 09:05:00 +0000</pubDate>
</item>
<item>
<title>Answered: How to use higher-order functions in PHP</title>
<link>https://collectivesolver.com/98127/how-to-use-higher-order-functions-in-php?show=98128#a98128</link>
<description>&lt;pre class=&quot;brush:php;&quot;&gt;// A higher‑order function is a function that does at least one of the following:
// 1. Takes another function as an argument
// 2. Returns a function as its result
// If it does either one, it qualifies.

// Higher-order function: takes a function as an argument
function applyTwice(callable $fn, int $x): int {
    return $fn($fn($x));
}

// A simple function to pass in
function add3(int $n): int {
    return $n + 3;
}

// Use the higher-order function
$result = applyTwice('add3', 5); // 5 + 3 = 8 + 3 = 11

echo $result . PHP_EOL;


/*
run:

11

*/&lt;/pre&gt;&lt;p&gt;&amp;nbsp;&lt;/p&gt;</description>
<guid isPermaLink="true">https://collectivesolver.com/98127/how-to-use-higher-order-functions-in-php?show=98128#a98128</guid>
<pubDate>Thu, 04 Jun 2026 08:58:18 +0000</pubDate>
</item>
<item>
<title>Answered: How to use higher-order functions in TypeScript</title>
<link>https://collectivesolver.com/98124/how-to-use-higher-order-functions-in-typescript?show=98126#a98126</link>
<description>&lt;pre class=&quot;brush:jscript;&quot;&gt;// A higher‑order function is a function that does at least one of the following:
// 1. Takes another function as an argument
// 2. Returns a function as its result
// If it does either one, it qualifies.

// makeMultiplier is a higher‑order function because it RETURNS another function
function makeMultiplier(n: number): (x: number) =&amp;gt; number {

    // This inner function forms a closure and remembers the value of n
    return function (x: number): number {
        return x * n; // Uses the captured value n
    };
}

// double_val is now a function created by makeMultiplier(2)
// It remembers n = 2 through closure
const double_val = makeMultiplier(2);

// Calling double_val(10) multiplies 10 by the captured n (which is 2)
console.log(double_val(10));



/*
run:

20

*/
&lt;/pre&gt;&lt;p&gt;&amp;nbsp;&lt;/p&gt;</description>
<guid isPermaLink="true">https://collectivesolver.com/98124/how-to-use-higher-order-functions-in-typescript?show=98126#a98126</guid>
<pubDate>Thu, 04 Jun 2026 08:53:00 +0000</pubDate>
</item>
<item>
<title>Answered: How to use higher-order functions in C#</title>
<link>https://collectivesolver.com/98121/how-to-use-higher-order-functions-in-c%23?show=98123#a98123</link>
<description>&lt;pre class=&quot;brush:csharp;&quot;&gt;using System;

class Program
{
    // A higher‑order function is a function that does at least one of the following:
    // 1. Takes another function as an argument
    // 2. Returns a function as its result
    // If it does either one, it qualifies.

    // makeMultiplier is a higher‑order function because it RETURNS another function
    static Func&amp;lt;int, int&amp;gt; makeMultiplier(int n) {
        // This inner function forms a closure and remembers the value of n
        return (int x) =&amp;gt; x * n; // Uses the captured value n
    }

    static void Main()
    {
        // double is now a function created by makeMultiplier(2)
        // It remembers n = 2 through closure
        var doubleFn = makeMultiplier(2);

        // Calling doubleFn(10) multiplies 10 by the captured n (which is 2)
        Console.WriteLine(doubleFn(10));
    }
}



/*
run:

20

*/
&lt;/pre&gt;&lt;p&gt;&amp;nbsp;&lt;/p&gt;</description>
<guid isPermaLink="true">https://collectivesolver.com/98121/how-to-use-higher-order-functions-in-c%23?show=98123#a98123</guid>
<pubDate>Thu, 04 Jun 2026 08:46:01 +0000</pubDate>
</item>
<item>
<title>Answered: How to use higher-order functions in VB.NET</title>
<link>https://collectivesolver.com/98118/how-to-use-higher-order-functions-in-vb-net?show=98120#a98120</link>
<description>&lt;pre class=&quot;brush:vb;&quot;&gt;Imports System

Module Program

    ' A higher‑order function is a function that does at least one of the following:
    ' 1. Takes another function as an argument
    ' 2. Returns a function as its result
    ' If it does either one, it qualifies.

    ' makeMultiplier is a higher‑order function because it RETURNS another function
    Function makeMultiplier(n As Integer) As Func(Of Integer, Integer)

        ' This inner function forms a closure and remembers the value of n
        Return Function(x As Integer) x * n ' Uses the captured value n

    End Function

    Sub Main()

        ' double is now a function created by makeMultiplier(2)
        ' It remembers n = 2 through closure
        Dim doubleFn As Func(Of Integer, Integer) = makeMultiplier(2)

        ' Calling doubleFn(10) multiplies 10 by the captured n (which is 2)
        Console.WriteLine(doubleFn(10))
    End Sub

End Module


	
' run:
'
' 20
'

&lt;/pre&gt;&lt;p&gt;&amp;nbsp;&lt;/p&gt;</description>
<guid isPermaLink="true">https://collectivesolver.com/98118/how-to-use-higher-order-functions-in-vb-net?show=98120#a98120</guid>
<pubDate>Thu, 04 Jun 2026 05:52:08 +0000</pubDate>
</item>
<item>
<title>Answered: How to use higher-order functions in Java</title>
<link>https://collectivesolver.com/98115/how-to-use-higher-order-functions-in-java?show=98117#a98117</link>
<description>&lt;pre class=&quot;brush:java;&quot;&gt;import java.util.function.Function;

public class ProgramClass {

    // A higher‑order function is a function that does at least one of the following:
    // 1. Takes another function as an argument
    // 2. Returns a function as its result
    // If it does either one, it qualifies.

    // makeMultiplier is a higher‑order function because it RETURNS another function
    static Function&amp;lt;Integer, Integer&amp;gt; makeMultiplier(int n) {

        // This inner function forms a closure and remembers the value of n
        return (Integer x) -&amp;gt; x * n; // Uses the captured value n
    }

    public static void main(String[] args) {

        // double is now a function created by makeMultiplier(2)
        // It remembers n = 2 through closure
        Function&amp;lt;Integer, Integer&amp;gt; doubleFn = makeMultiplier(2);

        // Calling doubleFn.apply(10) multiplies 10 by the captured n (which is 2)
        System.out.println(doubleFn.apply(10));
    }
}



/*
run:

20

*/&lt;/pre&gt;&lt;p&gt;&amp;nbsp;&lt;/p&gt;</description>
<guid isPermaLink="true">https://collectivesolver.com/98115/how-to-use-higher-order-functions-in-java?show=98117#a98117</guid>
<pubDate>Thu, 04 Jun 2026 05:48:30 +0000</pubDate>
</item>
<item>
<title>Answered: How to use higher-order functions in C</title>
<link>https://collectivesolver.com/98112/how-to-use-higher-order-functions-in-c?show=98114#a98114</link>
<description>&lt;pre class=&quot;brush:cpp;&quot;&gt;#include &amp;lt;stdio.h&amp;gt;

// A higher‑order function is a function that does at least one of the following:
// 1. Takes another function as an argument
// 2. Returns a function as its result
// If it does either one, it qualifies.

// We simulate a closure using a struct that stores state + a function pointer
typedef struct {
    int n;                       // captured value
    int (*fn)(int x, int n);     // function pointer that uses captured value
} Multiplier;

// Function used by the &quot;closure&quot;
int multiplyImpl(int x, int n) {
    return x * n; // Uses the captured value n
}

// makeMultiplier is a higher‑order function because it RETURNS another function-like object
Multiplier makeMultiplier(int n) {

    // This inner function forms a closure and remembers the value of n
    Multiplier m;
    m.n = n;
    m.fn = multiplyImpl;
    
    return m;
}

int main() {
    // double is now a function-like object created by makeMultiplier(2)
    // It remembers n = 2 through stored state
    Multiplier doubleFn = makeMultiplier(2);

    // Calling doubleFn.fn(10, doubleFn.n) multiplies 10 by the captured n (which is 2)
    printf(&quot;%d\n&quot;, doubleFn.fn(10, doubleFn.n));

    return 0;
}



/*
run:

20

*/&lt;/pre&gt;&lt;p&gt;&amp;nbsp;&lt;/p&gt;</description>
<guid isPermaLink="true">https://collectivesolver.com/98112/how-to-use-higher-order-functions-in-c?show=98114#a98114</guid>
<pubDate>Wed, 03 Jun 2026 17:26:35 +0000</pubDate>
</item>
<item>
<title>Answered: How to use higher-order functions in C++</title>
<link>https://collectivesolver.com/98109/how-to-use-higher-order-functions-in-c?show=98111#a98111</link>
<description>&lt;pre class=&quot;brush:cpp;&quot;&gt;#include &amp;lt;iostream&amp;gt;
#include &amp;lt;functional&amp;gt;

// A higher‑order function is a function that does at least one of the following:
// 1. Takes another function as an argument
// 2. Returns a function as its result
// If it does either one, it qualifies.

// makeMultiplier is a higher‑order function because it RETURNS another function
std::function&amp;lt;int(int)&amp;gt; makeMultiplier(int n) {

    // This inner function forms a closure and remembers the value of n
    return [n](int x) {
        return x * n; // Uses the captured value n
    };
}

int main() {
    // double is now a function created by makeMultiplier(2)
    // It remembers n = 2 through closure
    auto doubleFn = makeMultiplier(2);

    // Calling doubleFn(10) multiplies 10 by the captured n (which is 2)
    std::cout &amp;lt;&amp;lt; doubleFn(10) &amp;lt;&amp;lt; std::endl;
}



/*
run:

20

*/
&lt;/pre&gt;&lt;p&gt;&amp;nbsp;&lt;/p&gt;</description>
<guid isPermaLink="true">https://collectivesolver.com/98109/how-to-use-higher-order-functions-in-c?show=98111#a98111</guid>
<pubDate>Wed, 03 Jun 2026 16:52:28 +0000</pubDate>
</item>
<item>
<title>Answered: How to use higher-order functions in JavaScript</title>
<link>https://collectivesolver.com/98106/how-to-use-higher-order-functions-in-javascript?show=98108#a98108</link>
<description>&lt;pre class=&quot;brush:jscript;&quot;&gt;// A higher‑order function is a function that does at least one of the following:
// 1. Takes another function as an argument
// 2. Returns a function as its result
// If it does either one, it qualifies.
 
// makeMultiplier is a higher‑order function because it RETURNS another function
function makeMultiplier(n) {
 
    // This inner function forms a closure and remembers the value of n
    return function(x) {
        return x * n; // Uses the captured value n
    };
}
 
// double_val is now a function created by makeMultiplier(2)
// It remembers n = 2 through closure
const double_val = makeMultiplier(2);
 
// Calling double_val(10) multiplies 10 by the captured n (which is 2)
console.log(double_val(10));
 
 
/*
run:
 
20
 
*/&lt;/pre&gt;&lt;p&gt;&amp;nbsp;&lt;/p&gt;</description>
<guid isPermaLink="true">https://collectivesolver.com/98106/how-to-use-higher-order-functions-in-javascript?show=98108#a98108</guid>
<pubDate>Wed, 03 Jun 2026 16:28:59 +0000</pubDate>
</item>
<item>
<title>Answered: How to represent the ABCs as a 5-letter binary code using A for 0 and B for 1 in Java</title>
<link>https://collectivesolver.com/98104/how-to-represent-the-abcs-as-a-5-letter-binary-code-using-a-for-0-and-b-for-1-in-java?show=98105#a98105</link>
<description>&lt;pre class=&quot;brush:java;&quot;&gt;// a = AAAAA -&amp;gt; 00000 -&amp;gt; 0
// b = AAAAB -&amp;gt; 00001 -&amp;gt; 1
// c = AAABA -&amp;gt; 00010 -&amp;gt; 2
// d = AAABB -&amp;gt; 00011 -&amp;gt; 3
// e = AABAA -&amp;gt; 00100 -&amp;gt; 4
// f = AABAB -&amp;gt; 00101 -&amp;gt; 5
// g = AABBA -&amp;gt; 00110 -&amp;gt; 6

public class ABCode {

    // Convert integer n (0–31) into 5-letter A/B code
    static String toAB(int n) {
        StringBuilder out = new StringBuilder();

        for (int i = 4; i &amp;gt;= 0; --i) {
            int bit = (n &amp;gt;&amp;gt; i) &amp;amp; 1;   // extract bit
            out.append(bit == 1 ? 'B' : 'A');
        }

        return out.toString();
    }

    public static void main(String[] args) {
        for (char ch = 'a'; ch &amp;lt;= 'z'; ++ch) {
            int value = ch - 'a';      // a=0, b=1, c=2...
            String code = toAB(value);

            System.out.println(ch + &quot; -&amp;gt; &quot; + value + &quot; -&amp;gt; &quot; + code);
        }
    }
}


/*
run:

a -&amp;gt; 0 -&amp;gt; AAAAA
b -&amp;gt; 1 -&amp;gt; AAAAB
c -&amp;gt; 2 -&amp;gt; AAABA
d -&amp;gt; 3 -&amp;gt; AAABB
e -&amp;gt; 4 -&amp;gt; AABAA
f -&amp;gt; 5 -&amp;gt; AABAB
g -&amp;gt; 6 -&amp;gt; AABBA
h -&amp;gt; 7 -&amp;gt; AABBB
i -&amp;gt; 8 -&amp;gt; ABAAA
j -&amp;gt; 9 -&amp;gt; ABAAB
k -&amp;gt; 10 -&amp;gt; ABABA
l -&amp;gt; 11 -&amp;gt; ABABB
m -&amp;gt; 12 -&amp;gt; ABBAA
n -&amp;gt; 13 -&amp;gt; ABBAB
o -&amp;gt; 14 -&amp;gt; ABBBA
p -&amp;gt; 15 -&amp;gt; ABBBB
q -&amp;gt; 16 -&amp;gt; BAAAA
r -&amp;gt; 17 -&amp;gt; BAAAB
s -&amp;gt; 18 -&amp;gt; BAABA
t -&amp;gt; 19 -&amp;gt; BAABB
u -&amp;gt; 20 -&amp;gt; BABAA
v -&amp;gt; 21 -&amp;gt; BABAB
w -&amp;gt; 22 -&amp;gt; BABBA
x -&amp;gt; 23 -&amp;gt; BABBB
y -&amp;gt; 24 -&amp;gt; BBAAA
z -&amp;gt; 25 -&amp;gt; BBAAB

*/
&lt;/pre&gt;&lt;p&gt;&amp;nbsp;&lt;/p&gt;</description>
<guid isPermaLink="true">https://collectivesolver.com/98104/how-to-represent-the-abcs-as-a-5-letter-binary-code-using-a-for-0-and-b-for-1-in-java?show=98105#a98105</guid>
<pubDate>Wed, 03 Jun 2026 15:50:23 +0000</pubDate>
</item>
<item>
<title>Answered: How to represent the ABCs as a 5-letter binary code using A for 0 and B for 1 in Pascal</title>
<link>https://collectivesolver.com/98102/how-to-represent-the-abcs-as-a-5-letter-binary-code-using-a-for-0-and-b-for-1-in-pascal?show=98103#a98103</link>
<description>&lt;pre class=&quot;brush:delphi;&quot;&gt;program ABCode;

{$mode objfpc}

// a = AAAAA -&amp;gt; 00000 -&amp;gt; 0
// b = AAAAB -&amp;gt; 00001 -&amp;gt; 1
// c = AAABA -&amp;gt; 00010 -&amp;gt; 2
// d = AAABB -&amp;gt; 00011 -&amp;gt; 3
// e = AABAA -&amp;gt; 00100 -&amp;gt; 4
// f = AABAB -&amp;gt; 00101 -&amp;gt; 5
// g = AABBA -&amp;gt; 00110 -&amp;gt; 6

// Convert integer n (0–31) into 5-letter A/B code
function toAB(n: Integer): string;
var
  i, bit: Integer;
  outStr: string;
begin
  outStr := '';
  for i := 4 downto 0 do
  begin
    bit := (n shr i) and 1;       // extract bit
    if bit = 1 then
      outStr := outStr + 'B'
    else
      outStr := outStr + 'A';
  end;
  Result := outStr;
end;

var
  ch: Char;
  value: Integer;
  code: string;

begin
  for ch := 'a' to 'z' do
  begin
    value := Ord(ch) - Ord('a');   // a=0, b=1, c=2...
    code := toAB(value);

    WriteLn(ch, ' -&amp;gt; ', value, ' -&amp;gt; ', code);
  end;
end.


(*
run:

a -&amp;gt; 0 -&amp;gt; AAAAA
b -&amp;gt; 1 -&amp;gt; AAAAB
c -&amp;gt; 2 -&amp;gt; AAABA
d -&amp;gt; 3 -&amp;gt; AAABB
e -&amp;gt; 4 -&amp;gt; AABAA
f -&amp;gt; 5 -&amp;gt; AABAB
g -&amp;gt; 6 -&amp;gt; AABBA
h -&amp;gt; 7 -&amp;gt; AABBB
i -&amp;gt; 8 -&amp;gt; ABAAA
j -&amp;gt; 9 -&amp;gt; ABAAB
k -&amp;gt; 10 -&amp;gt; ABABA
l -&amp;gt; 11 -&amp;gt; ABABB
m -&amp;gt; 12 -&amp;gt; ABBAA
n -&amp;gt; 13 -&amp;gt; ABBAB
o -&amp;gt; 14 -&amp;gt; ABBBA
p -&amp;gt; 15 -&amp;gt; ABBBB
q -&amp;gt; 16 -&amp;gt; BAAAA
r -&amp;gt; 17 -&amp;gt; BAAAB
s -&amp;gt; 18 -&amp;gt; BAABA
t -&amp;gt; 19 -&amp;gt; BAABB
u -&amp;gt; 20 -&amp;gt; BABAA
v -&amp;gt; 21 -&amp;gt; BABAB
w -&amp;gt; 22 -&amp;gt; BABBA
x -&amp;gt; 23 -&amp;gt; BABBB
y -&amp;gt; 24 -&amp;gt; BBAAA
z -&amp;gt; 25 -&amp;gt; BBAAB

*)
&lt;/pre&gt;&lt;p&gt;&amp;nbsp;&lt;/p&gt;</description>
<guid isPermaLink="true">https://collectivesolver.com/98102/how-to-represent-the-abcs-as-a-5-letter-binary-code-using-a-for-0-and-b-for-1-in-pascal?show=98103#a98103</guid>
<pubDate>Wed, 03 Jun 2026 15:46:51 +0000</pubDate>
</item>
<item>
<title>Answered: How to use closure in Swift</title>
<link>https://collectivesolver.com/98097/how-to-use-closure-in-swift?show=98101#a98101</link>
<description>&lt;pre class=&quot;brush:jscript;&quot;&gt;// Closures inside higher‑order functions

let nums: [Int] = [1, 2, 3]
let factor: Int = 2

// map uses a closure that captures &quot;factor&quot;
let doubled: [Int] = nums.map { $0 * factor }

print(doubled)


/*
run:

[2, 4, 6]

*/
&lt;/pre&gt;&lt;p&gt;&amp;nbsp;&lt;/p&gt;</description>
<guid isPermaLink="true">https://collectivesolver.com/98097/how-to-use-closure-in-swift?show=98101#a98101</guid>
<pubDate>Wed, 03 Jun 2026 15:39:34 +0000</pubDate>
</item>
<item>
<title>How to use closure in Kotlin</title>
<link>https://collectivesolver.com/98092/how-to-use-closure-in-kotlin</link>
<description></description>
<guid isPermaLink="true">https://collectivesolver.com/98092/how-to-use-closure-in-kotlin</guid>
<pubDate>Wed, 03 Jun 2026 04:56:54 +0000</pubDate>
</item>
<item>
<title>How to use closure in Scala</title>
<link>https://collectivesolver.com/98087/how-to-use-closure-in-scala</link>
<description></description>
<guid isPermaLink="true">https://collectivesolver.com/98087/how-to-use-closure-in-scala</guid>
<pubDate>Wed, 03 Jun 2026 04:32:54 +0000</pubDate>
</item>
<item>
<title>How to use closure in Ruby</title>
<link>https://collectivesolver.com/98081/how-to-use-closure-in-ruby</link>
<description></description>
<guid isPermaLink="true">https://collectivesolver.com/98081/how-to-use-closure-in-ruby</guid>
<pubDate>Tue, 02 Jun 2026 16:03:29 +0000</pubDate>
</item>
<item>
<title>How to use closure in Go</title>
<link>https://collectivesolver.com/98076/how-to-use-closure-in-go</link>
<description></description>
<guid isPermaLink="true">https://collectivesolver.com/98076/how-to-use-closure-in-go</guid>
<pubDate>Tue, 02 Jun 2026 15:50:12 +0000</pubDate>
</item>
<item>
<title>How to use closure in TypeScript</title>
<link>https://collectivesolver.com/98071/how-to-use-closure-in-typescript</link>
<description></description>
<guid isPermaLink="true">https://collectivesolver.com/98071/how-to-use-closure-in-typescript</guid>
<pubDate>Tue, 02 Jun 2026 15:40:23 +0000</pubDate>
</item>
<item>
<title>How to use closure in JavaScript</title>
<link>https://collectivesolver.com/98067/how-to-use-closure-in-javascript</link>
<description></description>
<guid isPermaLink="true">https://collectivesolver.com/98067/how-to-use-closure-in-javascript</guid>
<pubDate>Tue, 02 Jun 2026 15:33:15 +0000</pubDate>
</item>
<item>
<title>How to use closure in Java</title>
<link>https://collectivesolver.com/98063/how-to-use-closure-in-java</link>
<description></description>
<guid isPermaLink="true">https://collectivesolver.com/98063/how-to-use-closure-in-java</guid>
<pubDate>Tue, 02 Jun 2026 13:10:28 +0000</pubDate>
</item>
<item>
<title>How to use closure in C++</title>
<link>https://collectivesolver.com/98059/how-to-use-closure-in-c</link>
<description></description>
<guid isPermaLink="true">https://collectivesolver.com/98059/how-to-use-closure-in-c</guid>
<pubDate>Tue, 02 Jun 2026 09:24:29 +0000</pubDate>
</item>
<item>
<title>How to use an anonymous function in Swift</title>
<link>https://collectivesolver.com/98056/how-to-use-an-anonymous-function-in-swift</link>
<description></description>
<guid isPermaLink="true">https://collectivesolver.com/98056/how-to-use-an-anonymous-function-in-swift</guid>
<pubDate>Tue, 02 Jun 2026 09:12:12 +0000</pubDate>
</item>
<item>
<title>How to use an anonymous function in Kotlin</title>
<link>https://collectivesolver.com/98052/how-to-use-an-anonymous-function-in-kotlin</link>
<description></description>
<guid isPermaLink="true">https://collectivesolver.com/98052/how-to-use-an-anonymous-function-in-kotlin</guid>
<pubDate>Tue, 02 Jun 2026 08:40:31 +0000</pubDate>
</item>
<item>
<title>How to use an anonymous function in Scala</title>
<link>https://collectivesolver.com/98048/how-to-use-an-anonymous-function-in-scala</link>
<description></description>
<guid isPermaLink="true">https://collectivesolver.com/98048/how-to-use-an-anonymous-function-in-scala</guid>
<pubDate>Tue, 02 Jun 2026 08:20:33 +0000</pubDate>
</item>
<item>
<title>How to use an anonymous function in Ruby</title>
<link>https://collectivesolver.com/98045/how-to-use-an-anonymous-function-in-ruby</link>
<description></description>
<guid isPermaLink="true">https://collectivesolver.com/98045/how-to-use-an-anonymous-function-in-ruby</guid>
<pubDate>Tue, 02 Jun 2026 08:14:19 +0000</pubDate>
</item>
<item>
<title>How to use an anonymous function in Rust</title>
<link>https://collectivesolver.com/98043/how-to-use-an-anonymous-function-in-rust</link>
<description></description>
<guid isPermaLink="true">https://collectivesolver.com/98043/how-to-use-an-anonymous-function-in-rust</guid>
<pubDate>Tue, 02 Jun 2026 08:08:59 +0000</pubDate>
</item>
<item>
<title>How to use an anonymous function in TypeScript</title>
<link>https://collectivesolver.com/98040/how-to-use-an-anonymous-function-in-typescript</link>
<description></description>
<guid isPermaLink="true">https://collectivesolver.com/98040/how-to-use-an-anonymous-function-in-typescript</guid>
<pubDate>Tue, 02 Jun 2026 07:57:03 +0000</pubDate>
</item>
<item>
<title>How to use an anonymous function in JavaScript</title>
<link>https://collectivesolver.com/98037/how-to-use-an-anonymous-function-in-javascript</link>
<description></description>
<guid isPermaLink="true">https://collectivesolver.com/98037/how-to-use-an-anonymous-function-in-javascript</guid>
<pubDate>Tue, 02 Jun 2026 07:49:17 +0000</pubDate>
</item>
<item>
<title>How to use an anonymous function in C#</title>
<link>https://collectivesolver.com/98035/how-to-use-an-anonymous-function-in-c%23</link>
<description></description>
<guid isPermaLink="true">https://collectivesolver.com/98035/how-to-use-an-anonymous-function-in-c%23</guid>
<pubDate>Tue, 02 Jun 2026 07:47:04 +0000</pubDate>
</item>
<item>
<title>How to use an anonymous function in VB.NET</title>
<link>https://collectivesolver.com/98033/how-to-use-an-anonymous-function-in-vb-net</link>
<description></description>
<guid isPermaLink="true">https://collectivesolver.com/98033/how-to-use-an-anonymous-function-in-vb-net</guid>
<pubDate>Tue, 02 Jun 2026 07:44:50 +0000</pubDate>
</item>
<item>
<title>How to use an anonymous function in Java</title>
<link>https://collectivesolver.com/98031/how-to-use-an-anonymous-function-in-java</link>
<description></description>
<guid isPermaLink="true">https://collectivesolver.com/98031/how-to-use-an-anonymous-function-in-java</guid>
<pubDate>Tue, 02 Jun 2026 06:47:38 +0000</pubDate>
</item>
<item>
<title>How to use an anonymous function in C++</title>
<link>https://collectivesolver.com/98029/how-to-use-an-anonymous-function-in-c</link>
<description></description>
<guid isPermaLink="true">https://collectivesolver.com/98029/how-to-use-an-anonymous-function-in-c</guid>
<pubDate>Tue, 02 Jun 2026 06:42:08 +0000</pubDate>
</item>
</channel>
</rss>