list = []
while True:
n = int(input("nb: "))
if n == 0:
break
list.append(n)
res = 1
sum = sum(list)
for x in list:
if x * x > sum:
res *= x
print(res)
def isPerfectSquare(num):
s = int(num**0.5)
return s * s == num
def isFibonacciNumber(n):
return isPerfectSquare(5 * n * n + 4) or isPerfectSquare(5 * n * n - 4)
n = int(input('nb : '))
if n % 2:
odd = n
if isFibonacciNumber(n):
print([x for x in list if not(x % 3)])
else:
print([x for x in list if not(x % 5)])
N = int(input('N = '))
for i in range(N):
print(sum([x for x in list if x * x % 10 == 9]))
class Program
{
static void Main(string[] args)
string src = " Qwy. ... Asdf.. Lkjdfs A.";
//string dest = ReplaceDots(src, '.', '…', 3);
string dest = ReplaceDots(src, '.', "...", 3);
Console.WriteLine("src:\t" + src);
Console.WriteLine("dest:\t" + dest);
Console.WriteLine();
Console.Write("Press any key for exit ...");
Console.ReadKey(true);
}
//private static string ReplaceDots(string src, char dotCh, char dots, int minDotsCount)
private static string ReplaceDots(string src, char dotCh, string dots, int minDotsCount)
StringBuilder dest = new StringBuilder();
int i = 0;
while (i < src.Length)
int dotsCount = 0;
while (i < src.Length && src[i] == dotCh)
dotsCount++;
i++;
if (dotsCount >= minDotsCount)
dest.Append(dots);
else if (dotsCount == 0)
dest.Append(src[i++]);
else
while (dotsCount-- > 0)
dest.Append(dotCh);
return dest.ToString(); ;
list = []
while True:
n = int(input("nb: "))
if n == 0:
break
list.append(n)
res = 1
sum = sum(list)
for x in list:
if x * x > sum:
res *= x
print(res)
# 2def isPerfectSquare(num):
s = int(num**0.5)
return s * s == num
def isFibonacciNumber(n):
return isPerfectSquare(5 * n * n + 4) or isPerfectSquare(5 * n * n - 4)
list = []
while True:
n = int(input('nb : '))
if n % 2:
odd = n
break
list.append(n)
if isFibonacciNumber(n):
print([x for x in list if not(x % 3)])
else:
print([x for x in list if not(x % 5)])
# 3list = []
N = int(input('N = '))
for i in range(N):
n = int(input('nb : '))
list.append(n)
print(sum([x for x in list if x * x % 10 == 9]))
class Program
{
static void Main(string[] args)
{
string src = " Qwy. ... Asdf.. Lkjdfs A.";
//string dest = ReplaceDots(src, '.', '…', 3);
string dest = ReplaceDots(src, '.', "...", 3);
Console.WriteLine("src:\t" + src);
Console.WriteLine("dest:\t" + dest);
Console.WriteLine();
Console.Write("Press any key for exit ...");
Console.ReadKey(true);
}
//private static string ReplaceDots(string src, char dotCh, char dots, int minDotsCount)
private static string ReplaceDots(string src, char dotCh, string dots, int minDotsCount)
{
StringBuilder dest = new StringBuilder();
int i = 0;
while (i < src.Length)
{
int dotsCount = 0;
while (i < src.Length && src[i] == dotCh)
{
dotsCount++;
i++;
}
if (dotsCount >= minDotsCount)
dest.Append(dots);
else if (dotsCount == 0)
dest.Append(src[i++]);
else
while (dotsCount-- > 0)
dest.Append(dotCh);
}
return dest.ToString(); ;
}
}